我使用AVCaptureSession
錄製視頻,會話預設爲AVCaptureSessionPreset640x480
。我在非標準尺寸(300 x 300)下使用AVCaptureVideoPreviewLayer
,並在錄製時將重力設置爲縱向填充。它的設置是這樣的:導出與預覽圖層大小相匹配的AVCaptureSession視頻
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
_previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
_previewLayer.frame = _previewView.bounds; // 300 x 300
[_previewView.layer addSublayer:_previewLayer];
在錄製視頻後,我想以快速格式將其寫入文件。在播放過程中,我再次以300 x 300的非標準尺寸圖層播放視頻。由於這些視頻最終將通過網絡連接進行傳輸,因此保留完整的640x480視頻看起來很浪費。
導出視頻以匹配我的300 x 300預覽圖層的最佳方式是什麼?我是AVFoundation noob,所以如果我以錯誤的方式討論這個問題,請告訴我。我只是希望錄製過程中預覽圖層中顯示的錄製視頻與磁盤上導出的視頻相匹配。
我認爲這[答案] [1]應該可以幫助你。 [1]:http://stackoverflow.com/a/16910263/2315453 – arunit21 2013-06-04 05:31:57