Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVVideoProfileLevelH264High41 breaking on iPhone 4

I am using AVAssetWriter to compress a video, the code works in both iPhone 5 and 4 in iOS7. I am attempting to use the AVVideoProfileLevelKey of AVVideoProfileLevelH264High41 to attain better compression than that of Baseline or Main profiles. The code works in iOS7 with an iPhone 5, but breaks on an iPhone 4 with the following error. Most of these profiles listed in the error below additionally do not work.

Does anyone know if High profiles for compression don't work on iPhone 4, Apples documentation only states that it requires iOS6 or higher.

> 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];
like image 326
Harper LaFave Avatar asked Dec 11 '13 10:12

Harper LaFave


1 Answers

You can't encode in ProfileLevelH264High41 with iPhone4, it is only supported from iPhone4S

like image 117
HaneTV Avatar answered Oct 30 '22 11:10

HaneTV