Ios AVAssetWriter在iPhone X分辨率为w/h.264但不为w/h.265时失败

Ios AVAssetWriter在iPhone X分辨率为w/h.264但不为w/h.265时失败,ios,avfoundation,h.264,avassetwriter,hevc,Ios,Avfoundation,H.264,Avassetwriter,Hevc,我正在使用AVAssetWriter编写实时视频,添加CMSampleBufferRefs流 我选择的输出分辨率之一是1376 x 2436(对于iPhoneX,增加了一些宽度,以满足1.77的纵横比) 奇怪的是。。。当我把它输出为HEVC时,一切都很好。但是,如果我选择h.264(因为只有iPhone7以后的版本才能生产HEVC,而iPhone5s上的某个人可能正在与iPhoneX上的某个人通话),写操作就失败了 Error Domain = AVFoundationErrorDomain

我正在使用AVAssetWriter编写实时视频,添加
CMSampleBufferRef
s流

我选择的输出分辨率之一是1376 x 2436(对于iPhoneX,增加了一些宽度,以满足1.77的纵横比)

奇怪的是。。。当我把它输出为HEVC时,一切都很好。但是,如果我选择h.264(因为只有iPhone7以后的版本才能生产HEVC,而iPhone5s上的某个人可能正在与iPhoneX上的某个人通话),写操作就失败了

Error Domain = AVFoundationErrorDomain 
Code = -11800 
"The operation could not be completed" 
UserInfo = {
   NSLocalizedFailureReason = An unknown error occurred (-12902), 
   NSLocalizedDescription = The operation could not be completed, 
   NSUnderlyingError = 0x1c424b550 {
      Error Domain = NSOSStatusErrorDomain Code=-12902 "(null)"
   }
 }
h.264设置适用于所有其他输出分辨率:640x1136、750x1334和1080x1920

h、 264输出设置:

@{   AVVideoCodecKey:AVVideoCodecH264,
     AVVideoWidthKey:@(mediaSize.width),
     AVVideoHeightKey:@(mediaSize.height),
     AVVideoCompressionPropertiesKey:@{
                        AVVideoAverageBitRateKey: @4500000,
                        AVVideoAllowFrameReorderingKey:@NO,
                        AVVideoProfileLevelKey: AVVideoProfileLevelH264High41,
                        AVVideoH264EntropyModeKey:AVVideoH264EntropyModeCABAC,
                        AVVideoExpectedSourceFrameRateKey: @(30)
                        }
     };
@{ AVVideoCodecKey:AVVideoCodecTypeHEVC,
   AVVideoWidthKey:@(mediaSize.width),
   AVVideoHeightKey:@(mediaSize.height),
   AVVideoCompressionPropertiesKey:@{
        AVVideoProfileLevelKey : (__bridge NSString *)kVTProfileLevel_HEVC_Main_AutoLevel,
        AVVideoAverageBitRateKey: @4500000,
        AVVideoAllowFrameReorderingKey:@NO,
        AVVideoExpectedSourceFrameRateKey: @(30)
        }
};
hevc输出设置:

@{   AVVideoCodecKey:AVVideoCodecH264,
     AVVideoWidthKey:@(mediaSize.width),
     AVVideoHeightKey:@(mediaSize.height),
     AVVideoCompressionPropertiesKey:@{
                        AVVideoAverageBitRateKey: @4500000,
                        AVVideoAllowFrameReorderingKey:@NO,
                        AVVideoProfileLevelKey: AVVideoProfileLevelH264High41,
                        AVVideoH264EntropyModeKey:AVVideoH264EntropyModeCABAC,
                        AVVideoExpectedSourceFrameRateKey: @(30)
                        }
     };
@{ AVVideoCodecKey:AVVideoCodecTypeHEVC,
   AVVideoWidthKey:@(mediaSize.width),
   AVVideoHeightKey:@(mediaSize.height),
   AVVideoCompressionPropertiesKey:@{
        AVVideoProfileLevelKey : (__bridge NSString *)kVTProfileLevel_HEVC_Main_AutoLevel,
        AVVideoAverageBitRateKey: @4500000,
        AVVideoAllowFrameReorderingKey:@NO,
        AVVideoExpectedSourceFrameRateKey: @(30)
        }
};