iPhone 4上的AVVideoProfileLevelH264High41中断
我正在使用iPhone 4上的AVVideoProfileLevelH264High41中断,iphone,objective-c,xcode,avassetwriter,Iphone,Objective C,Xcode,Avassetwriter,我正在使用AVAssetWriter压缩视频,该代码在iOS7的iphone5和iphone4中都可以使用。我试图使用AVVideoProfileLevelH264High41的AVVideoProfileLevelKey来获得比基线或主配置文件更好的压缩。该代码在iOS7和iPhone5中工作,但在iPhone4中出现以下错误。此外,下面错误中列出的大多数配置文件都不起作用 有人知道高配置压缩在iPhone4上是否不起作用吗?苹果公司的文档仅说明它需要iOS6或更高版本 > 2013-1
AVAssetWriter
压缩视频,该代码在iOS7的iphone5和iphone4中都可以使用。我试图使用AVVideoProfileLevelH264High41
的AVVideoProfileLevelKey
来获得比基线或主配置文件更好的压缩。该代码在iOS7和iPhone5中工作,但在iPhone4中出现以下错误。此外,下面错误中列出的大多数配置文件都不起作用
有人知道高配置压缩在iPhone4上是否不起作用吗?苹果公司的文档仅说明它需要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];
iPhone4无法在ProfileLevelH264High41中编码,它仅在iPhone4S中受支持代码正在崩溃,请执行未捕获的
nsilegalargumentException
。因此,我猜测,也许iOS 6和iOS 7中的参数不同,即使该方法本身可能已经存在。感谢SevenBits,为了澄清无法工作的iPhone4也在运行iOS 7。