首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVCaptureMovieFileOutput -如何保存视频

AVCaptureMovieFileOutput -如何保存视频
EN

Stack Overflow用户
提问于 2011-08-16 05:59:17
回答 1查看 4.3K关注 0票数 4

我使用以下代码来捕获视频并将其保存到我的应用程序的documents文件夹中:

代码语言:javascript
复制
        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];后对整个视频进行处理之前将整个视频缓冲在内存中?

如果这种方法不适合录制如此长时间的视频,那么什么可能是一个合理的替代方案?

谢谢,詹姆斯

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-16 07:31:41

可以肯定的是,AVCaptureMovieFileOutput会附加到文件中,并且不会使用内存中的缓冲区(也许会使用,但它会在文件变得太大之前将其刷新到文件中)...some这方面的证据可以在movieFragmentInterval属性here中看到。我也使用这个方法来记录大文件的文件,它工作得很好,如果它将文件保存在内存中,在某些预设(例如1280x720)下会很快耗尽内存。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7071312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档