AVAssetWriter 多个会话和状态属性
我正在尝试使用 AVAssetWriter 创建多个串行写入会话。一旦我成功完成一项(调用 finishWriting 后),状态就会设置为 2 (AVAssetWriterStatusCompleted)。
尝试创建另一个会话,我调用 startWriting,但收到错误:
[AVAssetWriter startWriting] cannot call method when status is 2
除非配置某些内容,否则似乎无法创建写入会话。我必须再次重新创建 AVAssetWriter 吗?我一定错过了一些东西,而且文档没有帮助。
谢谢。
I am attempting to create multiple, serial writing sessions with AVAssetWriter. Once I've completed one successfully (after calling finishWriting) the status is set to 2 (AVAssetWriterStatusCompleted).
Trying to create another session, I call startWriting, but I get the error:
[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? I must be missing something, and the docs aren't helping.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作者完成后,它就不再可用。您必须创建一个新的。从文档中:
您只能使用 AVAssetWriter 的给定实例一次来写入单个文件。
如果要多次写入文件,则必须使用新的实例
AVAssetWriter 每次。
我有一个应用程序,我使用两个 AVAssetWriters。我创建了两个作家,其中一次只有一个活跃。当达到某个时间增量时,我将活动写入器推送到 GCD 队列以完成和重新创建,并将活动写入器指针设置为另一个写入器。
当使用捕获队列时,这很有效。您可以设置一个开关来执行给定写入器状态的操作。
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.
This works well when using a capture queue. You can setup a switch to perform the operations given the state of the writer.