在后台启动AVAssetExportSession

我的应用程序做了一些处理,在某些时候需要调用一个AVAssetExportSession。

如果会话已经开始,然后我背景的应用程序,一切正常完成。 但是,如果我在调用exportAsynchronouslyWithCompletionHandler之前后台应用程序。 我得到这个错误:

AVAssetExportSessionStatusFailed Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1e550db0 {NSLocalizedFailureReason=An unknown error occurred (-12985), NSUnderlyingError=0x1e574910 "The operation couldn’t be completed. (OSStatus error -12985.)", NSLocalizedDescription=The operation could not be completed}

是否有可能在后台启动AVAssetExportSession?

这实际上是不可能的,因为你不能在后台启动一个新的线程。 如果你想在后台做很多事情,你必须在应用背景之前asynchronous启动它们。

您可以在后台启动AVAssetExportSessionAVFoundation在后台执行工作的唯一限制是使用AVVideoCompositionsAVMutableVideoCompositionsAVVideoCompositions正在使用GPU,并且GPU不能在后台使用。

我find了一个适用于audio的解决scheme,我没有试过video

如果您在项目的function中更新“背景模式”设置以包含audio。 这将允许出口。

这是为了在后台播放音乐。