[英]AVAssetWriter multiple sessions and the status property
I am attempting to create multiple, serial writing sessions with AVAssetWriter. 我正在尝试使用AVAssetWriter创建多个串行写入会话。 Once I've completed one successfully (after calling finishWriting) the status is set to 2 (AVAssetWriterStatusCompleted).
一旦我成功完成一个(在调用finishWriting之后),状态将设置为2(AVAssetWriterStatusCompleted)。
Trying to create another session, I call startWriting, but I get the error: 尝试创建另一个会话,我调用startWriting,但我收到错误:
[AVAssetWriter startWriting] cannot call method when status is 2
Seems I cannot create a writing session unless I configure something. 似乎我无法创建写入会话,除非我配置一些东西。 Do I have to recreate the AVAssetWriter again?
我是否必须再次重新创建AVAssetWriter? I must be missing something, and the docs aren't helping.
我必须遗漏一些东西,而且文档没有帮助。
Thanks. 谢谢。
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. 您只能使用给定的AVAssetWriter实例一次写入单个文件。 If you want to write to files multiple times, you must use a new instance of AVAssetWriter each time.
如果要多次写入文件,则每次都必须使用新的AVAssetWriter实例。
I have an app where I use two AVAssetWriters. 我有一个应用程序,我使用两个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.
当达到某个时间增量时,我将活动的writer写入GCD队列以完成和重新创建,并将活动的writer指针设置为另一个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.
您可以设置一个开关来执行给定状态的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.