Duck
Duck

Reputation: 35953

Capturing video on iOS: what is the difference between capturing video using AVMovieFileOutput or AVAssetWriter?

I am following this tutorial on how to capture video on iOS.

When you download their sample code and run it, it shows two methods of capturing video, using AVMovieFileOutput and using AVAssetWriter.

What is the technical difference between the two methods? is one better than the other?

Upvotes: 1

Views: 155

Answers (1)

Gordon Childs
Gordon Childs

Reputation: 36084

Both AVMovieFileOutput and AVAssetWriter (in conjunction with AVCaptureVideoDataOutput) allow you to capture media samples to files, but AVAssetWriter is the lower level and more configurable* of the two interfaces, so with AVAssetWriter / AVCaptureVideoDataOutput you can intercept and modify media samples before they are written which allows you to apply effects, and stream off the device, etc.

Last time I checked you couldn't add both AVMovieFileOutput and AVCaptureVideoDataOutput to an iOS capture session, so as soon as you want to examine and record the data flowing through the session in real time, you have no choice but to use AVAssetWriter / AVCaptureVideoDataOutput.

*in fact AVMovieFileOutput is probably implemented using AVAssetWriter.

Upvotes: 4

Related Questions