Pause Recording on iPhone

I’ve written an example iPhone app that shows how to pause and resume video recording on an iPhone. Instead of using a movie file output that would record directly from the camera, this sample uses a Data Output which forwards the captured video and audio to the app. The app then forwards this to an AVAssetWriter when recording is enabled.

After a pause and resume, the timestamps need to be adjusted (or there will be a pause in the video). The sample does this using CMSampleBufferCreateCopyWithNewTiming, since there isn’t any way to change the sample times for audio (for video, you can use a pixel buffer adapter).

The app is very basic, but it is fully functional and is published in source form under an attribution license.

Download the sample here.

Update: See also this note on resuming after the app enters background mode.

For another iPhone capture example, see this sample, which demonstrates how to get the compressed video and audio from AVAssetWriter for network streaming:

27th February 2013