I am recording video AVCaptureSessionwith pre-setting session AVCaptureSessionPreset640x480. I use AVCaptureVideoPreviewLayera non-standard size (300 x 300) with a gravity factor set to fill the aspect during recording. It is configured as follows:
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
_previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
_previewLayer.frame = _previewView.bounds; // 300 x 300
[_previewView.layer addSublayer:_previewLayer]
After recording the video, I want to write it to a file in QuickTime format. During playback, I play videos again in a non-standard size of 300 x 300. Since these videos will eventually be transferred over a network connection, it seems wasteful to store the full 640x480 video.
What is the best way to export video according to the 300 x 300 preview layer? I am an AVFoundation noob, so if I am going to do it wrong, please let me know. I just want the recorded video displayed at the preview level during recording to match the video that is exported to disk.
source
share