AVAssetWriter multiple sessions and the status property

时间秒杀一切 提交于 2019-12-03 00:24:52

After the writer has completed it is no longer usable. You must create a new one. From the docs:

You can only use a given instance of AVAssetWriter once to write to a single file. If you want to write to files multiple times, you must use a new instance of AVAssetWriter each time.

I have an app where I use two AVAssetWriters. I create two writers where only one is active at a time. When some time delta is reached I push the active writer onto a GCD queue for completion and recreation, and set the active writer pointer to the other writer.

if(time > delta)
  dispatch( ^{ finish writer, create new one })
  active_writer = next writer

This works well when using a capture queue. You can setup a switch to perform the operations given the state of the writer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!