iPhone 4上的AVVideoProfileLevelH264High41打破了

Har*_*ave 10 iphone xcode objective-c avassetwriter

AVAssetWriter用来压缩视频,代码适用于iOS7中的iPhone 5和4.我试图使用AVVideoProfileLevelKeyof AVVideoProfileLevelH264High41来获得比Baseline或Main配置文件更好的压缩效果.该代码在iOS7中使用iPhone 5,但在iPhone 4上出现以下错误.下面的错误中列出的大多数这些配置文件另外不起作用.

有谁知道如果用于压缩的High配置文件在iPhone 4上不起作用,Apples文档仅表明它需要iOS6或更高版本.

> 2013-12-10 18:26:37.637 VideoCompression[677:3707] *** Terminating app

> due to uncaught exception 'NSInvalidArgumentException', reason: '***

> `-[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:]` For compression
> property ProfileLevel, video codec type avc1 only allows the following

> values: H264_Baseline_1_3, H264_Baseline_3_0, H264_Baseline_3_1,

> H264_Baseline_4_1, H264_Main_3_0, H264_Main_3_1, H264_Main_3_2,

> H264_Main_4_0, H264_Main_4_1, H264_Main_5_0, H264_High_5_0,

> H264_Baseline_AutoLevel, H264_Main_AutoLevel, H264_High_AutoLevel'

> *** First throw call stack: (0x2fd76f4b 0x3a1066af 0x2ec5d833 0x2ec5d70b 0x2ec5d67d
 0xbd001 0xbba59 0x3a5e9d1b 0x3a5ea293 0x3a5ea6f7

> 0x3a5fc8f9 0x3a5fcb79 0x3a72bdbf 0x3a72bc84) libc++abi.dylib:

> terminating with uncaught exception of type NSException
NSDictionary *codecSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                           [NSNumber numberWithInteger:[bitrateTF.text intValue]], AVVideoAverageBitRateKey,
                                           [NSNumber numberWithInt:[maxkeyframeintervalTF.text intValue]],AVVideoMaxKeyFrameIntervalKey,
                                           **AVVideoProfileLevelH264High41,AVVideoProfileLevelKey,**
                                           videoCleanApertureSettings, AVVideoCleanApertureKey,
                                           videoAspectRatioSettings, AVVideoPixelAspectRatioKey,
                                           nil];

NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                       AVVideoCodecH264, AVVideoCodecKey,
                                       AVVideoScalingModeResizeAspectFill, AVVideoScalingModeKey,
                                       codecSettings,AVVideoCompressionPropertiesKey,
                                       [NSNumber numberWithInt:[widthTF.text intValue]], AVVideoWidthKey,
                                       [NSNumber numberWithInt:[heightTF.text intValue]], AVVideoHeightKey,
                                       //AVVideoScalingModeFit,AVVideoScalingModeKey,
                                       nil];
self.assetWriterVideoInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];
self.assetWriterVideoInput.transform = self.transformAssetWriter;
[self.assetWriter addInput:self.assetWriterVideoInput];
Run Code Online (Sandbox Code Playgroud)

Han*_*eTV 3

您无法使用 iPhone4 在 ProfileLevelH264High41 中进行编码,仅 iPhone4S 支持