AVAssetWriter 多个会话和状态属性

发布于 2024-10-15 20:09:41 字数 333 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

够钟 2024-10-22 20:09:41

作者完成后,它就不再可用。您必须创建一个新的。从文档中:

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

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

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

当使用捕获队列时,这很有效。您可以设置一个开关来执行给定写入器状态的操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文