我使用以下代码来捕获视频并将其保存到我的应用程序的documents文件夹中:
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] error:NULL];
m_captureFileOutput = [[AVCaptureMovieFileOutput alloc] init];
captureSession = [[AVCaptureSession alloc] init];
[captureSession addInput:captureInput];
[captureSession addOutput:m_captureFileOutput];
[captureSession beginConfiguration];
[captureSession setSessionPreset:AVCaptureSessionPresetHigh];
[captureSession commitConfiguration];
[captureSession startRunning];
...some function that starts the recording process...
[m_captureFileOutput startRecordingToOutputFileURL:url recordingDelegate:self];
...some function that ends the recording process...
[m_captureFileOutput stopRecording];关键是,我的目标是能够一次录制长达9小时的视频。实际上,用这种方法录制这种大小的视频是可行的吗?AVCaptureMovieFileOutput是在从摄像头接收帧时对视频进行实时编码并将其保存到磁盘上,还是在调用[m_captureFileOutput stopRecording];后对整个视频进行处理之前将整个视频缓冲在内存中?
如果这种方法不适合录制如此长时间的视频,那么什么可能是一个合理的替代方案?
谢谢,詹姆斯
发布于 2011-08-16 07:31:41
可以肯定的是,AVCaptureMovieFileOutput会附加到文件中,并且不会使用内存中的缓冲区(也许会使用,但它会在文件变得太大之前将其刷新到文件中)...some这方面的证据可以在movieFragmentInterval属性here中看到。我也使用这个方法来记录大文件的文件,它工作得很好,如果它将文件保存在内存中,在某些预设(例如1280x720)下会很快耗尽内存。
https://stackoverflow.com/questions/7071312
复制相似问题