问题
I am recording an MOV file using AVFoundation but im having trouble finding out how to change the dimensions of the video. I have videoGravity property of captureVideoPreviewLayer set to AVLayerVideoGravityResizeAspectFill and the UIView showing the preview layer has custom dimensions (not the same aspect ratio of the screen).
Recording works fine but the dimensions of the recorded video are the same as the aspect ratio of the screen. How can i record with the aspect ratio of the UIView or the preview layer?
回答1:
Here is best sample code to record video using AVFoundation
https://developer.apple.com/library/ios/#samplecode/RosyWriter/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011110
In File: RosyWriterVideoProcessor.m
Method Name
- (BOOL) setupAssetWriterVideoInput:(CMFormatDescriptionRef)currentFormatDescription
In videoCompressionSettings you can change dimension, hope this will help you.
来源:https://stackoverflow.com/questions/9338029/record-video-with-avfoundation-with-custom-dimensions