Search code examples
swiftavfoundationavassetwriteravasset

Use two AVAssetWriters simultaneously to create two version of same video input


If you want to create two versions of the same video input, one filtered and one untouched, are there drawbacks to using two AVAssetWriters simultaneously?

According to this SO post, it's not possible (at least in 2011) to use AVCaptureVideoDataOutput together with AVCaptureMovieFileOutput, so hopefully using two AVAssetWriters together solves the problem. Just would like to know if there are non-obvious gotchas to be aware of.


Solution

  • We've used two AVAssetWriters without an issue. There's no real "gotchas" I can think of, but some considerations:

    • Obviously the older the hardware, the more it's going to struggle (we're using iPhone 6's and up with no issues at all).
    • Size of the output file makes a difference to performance, so for fastest compilation, consider smaller resolutions.
    • It's unclear if you're compositing live or post-processing. If you're post-processing, you shouldn't have any issues (other than it will be slightly slower), but if you're writing live, then you might see missed buffers if performance is suffering.

    In my experience of trying this, can't see any reason not to give the solution a go, it should work fine.