Starting AVAssetExportSession in the Background

旧时模样 提交于 2019-11-28 00:13:50

问题


My app does some processing and at some point it needs to call an 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. 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?


回答1:


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.




回答2:


You can start AVAssetExportSession in background. The only limitations in AVFoundation to performing work in the background, are using AVVideoCompositions or AVMutableVideoCompositions. AVVideoCompositions are using the GPU, and the GPU cannot be used in the background.




回答3:


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.



来源:https://stackoverflow.com/questions/9846653/starting-avassetexportsession-in-the-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!