AVAssetWriter多个会话和status属性 [英] AVAssetWriter multiple sessions and the status property

查看:206
本文介绍了AVAssetWriter多个会话和status属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用AVAssetWriter创建多个串行写入会话。一旦我成功完成一个(在调用finishWriting之后)状态设置为2(AVAssetWriterStatusCompleted)。

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).

尝试创建另一个会话,我调用startWriting,但是我得到了错误:

Trying to create another session, I call startWriting, but I get the error:

[AVAssetWriter startWriting] cannot call method when status is 2

似乎我无法创建写入会话,除非我配置了什么。我是否必须再次重新创建AVAssetWriter?我必须遗漏一些东西,而且文档没有帮助。

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.

谢谢。

推荐答案

作家完成后就没有了更长的可用。您必须创建一个新的。来自文档:

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

您只能使用给定的AVAssetWriter实例一次写入单个文件。
如果你想多次写文件,你每次都必须使用
AVAssetWriter的新实例。

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.

我有一个应用程序我在哪里使用两个AVAssetWriters。我创建了两个编写器,其中一次只有一个是活动的。当达到某个时间增量时,我将活动的writer写入GCD队列以完成和重新创建,并将活动的writer指针设置为另一个writer。

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.

这篇关于AVAssetWriter多个会话和status属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆