简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM