Pause and resume video capture for the same file with AVFoundation in iOS

I’m trying to understand how I can implement functionality to repeatedly pause and resume video capture in one session, but each new segment (captured segments after each pause) is added to the same video file with AVFoundation. Currently, every time I click β€œstop” and then β€œrecord” again, it just saves a new video file on my iphone album and starts recording in a separate / new file. I need to press the record / stop button again and again ... only capture video and audio when the recording is active ... then when the done button is pressed, you have one AV file with all segments together. And all this should happen in the same capture / preview session.

the only way I can try to do this is to click the "done" button, taking each separate output file and combining them together into one file ... But I am sure that the processing time for inserting a bunch of separate clips together will not be acceptable. Also, it looks like it will be a very dirty and unnecessary way to get around this using too much code.

Is there an easy way to just pause video capture for one session and just resume capturing to the same file? Or any other ideas?

If this is not a big problem, the sample code will help me get a ton ... I am still learning and teaching myself, so I don’t really understand the explanations and terminology. Thanks

edit: this is the project I'm starting to learn AVFoundation with ... so this is the code I want to change to achieve the above functions: http://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro .html

+8
ios objective-c iphone video-capture avfoundation
source share
3 answers

Instead of using the output video file from the capture session, you can use AVCaptureVideoDataOutput and transfer samples to your AVAssetWriterInput instance in your deletion. You can then separate the preview from the recording. If your delegate does not forward buffers to the data writer, there is no entry for this part.

If you want to start recording the second (and subsequent) session to the same file, you will need to adjust the timestamps so that they are sequentially from the point at which you stopped, and you will need to make sure that you make the same setting as for audio , so for the video so that they stay in the sink. So a little hesitant, but certainly doable.

Edit: There is an example iPhone app that demonstrates this at http://www.gdcl.co.uk/2013/02/20/iPhone-Pause.html

FROM

+10
source share

In general, I use startRunning and stopRunning if I use AVCaptureSession. I guess you will do it.

See the documentation for AVCaptureSession.

+1
source share

You can just use HBRecorder . HBRecorder is a video recording tool with a pause / start function and great animation between video segments.

0
source share

All Articles