James
James

Reputation: 2282

AVCaptureMovieFileOutput - how it saves video

I am using the following code to capture video and save it to the documents folder of my app:

        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];

The catch is, my goal is to be able to record up to 9 hours of video at a time. Practically, is is feasible to record a video of this size using this method? Does AVCaptureMovieFileOutput encode and save the video to the disk in real time as it receives frames from the camera, or is the entire video buffered in RAM before being processed after [m_captureFileOutput stopRecording]; is called?

If this approach is not reasonable for recording such a long duration of video, what might be a reasonable alternative?

Thanks, James

Upvotes: 4

Views: 4432

Answers (1)

Daniel
Daniel

Reputation: 22395

Pretty sure the AVCaptureMovieFileOutput appends to the file and does not use a in memory buffer (maybe it does but it flushes it to the file before it gets too large)...some evidence of this can be seen in the movieFragmentInterval property here. Also i have used this method to record to a file for large files, and it works ok, if it was keeping the file in memory one would run out of memory pretty quickly under some presets (1280x720 for example)

Upvotes: 4

Related Questions