I'm using an AVAssetWriter to write realtime video, appending the stream of
CMSampleBufferRefs.One of my chosen output resolutions is 1376 x 2436 (for the iPhone X, adding some width so it meets a 1.77 aspect ratio).
Weird thing is... when I output it as HEVC, everything is great. But if I elect for h.264 (as only iPhone 7 onward can produce HEVC, yet someone on an iPhone 5s could be talking to someone on an iPhone X), the write fails.
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)"
}
}the h.264 settings work for all other output resolutions: 640x1136, 750x1334 and 1080x1920
h.264 output settings:
@{ AVVideoCodecKey:AVVideoCodecH264,
AVVideoWidthKey:@(mediaSize.width),
AVVideoHeightKey:@(mediaSize.height),
AVVideoCompressionPropertiesKey: @{
AVVideoAverageBitRateKey: @4500000,
AVVideoAllowFrameReorderingKey:@NO,
AVVideoProfileLevelKey: AVVideoProfileLevelH264High41,
AVVideoH264EntropyModeKey:AVVideoH264EntropyModeCABAC,
AVVideoExpectedSourceFrameRateKey: @(30)
}
};hevc output settings:
@{ AVVideoCodecKey:AVVideoCodecTypeHEVC,
AVVideoWidthKey:@(mediaSize.width),
AVVideoHeightKey:@(mediaSize.height),
AVVideoCompressionPropertiesKey:@{
AVVideoProfileLevelKey : (__bridge NSString *)kVTProfileLevel_HEVC_Main_AutoLevel,
AVVideoAverageBitRateKey: @4500000,
AVVideoAllowFrameReorderingKey:@NO,
AVVideoExpectedSourceFrameRateKey: @(30)
}
};