With AVCaptureSession
and AVAssetWriter
you can set the compression settings as such:
NSDictionary *settings = @{AVVideoCodecKey:AVVideoCodecH264,
AVVideoWidthKey:@(video_width),
AVVideoHeightKey:@(video_height),
AVVideoCompressionPropertiesKey:
@{AVVideoAverageBitRateKey:@(desired_bitrate),
AVVideoProfileLevelKey:AVVideoProfileLevelH264Main31, /* Or whatever profile & level you wish to use */
AVVideoMaxKeyFrameIntervalKey:@(desired_keyframe_interval)}};
AVAssetWriterInput* writer_input = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:settings];
Edit: I guess if you insist on using the UIImagePicker
to create the movie in the first place, you’ll have to use AVAssetReader's
copyNextSampleBuffer
and AVAssetWriter's
appendSampleBuffer
methods to do the transcode.