简体   繁体   English

在后台启动AVAssetExportSession

[英]Starting AVAssetExportSession in the Background

My app does some processing and at some point it needs to call an AVAssetExportSession. 我的应用程序做了一些处理,在某些时候它需要调用AVAssetExportSession。

If the session has already started and then I background the app, everything completes normally. 如果会话已经开始,然后我对应用程序进行后台处理,一切都正常完成。 However, if I background the app before calling exportAsynchronouslyWithCompletionHandler . 但是,如果我在调用exportAsynchronouslyWithCompletionHandler之前对应用程序进行后台exportAsynchronouslyWithCompletionHandler I get this error: 我收到此错误:

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}

Is it possible to start an AVAssetExportSession in the background? 是否可以在后台启动AVAssetExportSession?

It actually is not possible due to the fact that you can't start a new thread in the background. 实际上,由于您无法在后台启动新线程,因此无法实现。 If you want to do a lot of things in the background you'll have to start them all asynchronously right before the app backgrounds. 如果你想在后台做很多事情,你必须在app背景之前异步启动它们。

You can start AVAssetExportSession in background. 您可以在后台启动AVAssetExportSession The only limitations in AVFoundation to performing work in the background, are using AVVideoCompositions or AVMutableVideoCompositions . AVFoundation在后台执行工作的唯一限制是使用AVVideoCompositionsAVMutableVideoCompositions AVVideoCompositions are using the GPU, and the GPU cannot be used in the background. AVVideoCompositions正在使用GPU,GPU无法在后台使用。

I have found a solution which works for audio, I have not tried video 我找到了适用于音频的解决方案,我还没有尝试过视频

If you update your "Background Modes" setting in the capabilities of the project to include Audio. 如果更新项目功能中的“后台模式”设置以包含音频。 It will allow the export. 它将允许出口。

This is intended for playing music in the background. 这是为了在后台播放音乐。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM