问题
I am working on one application in which it requires to merge more than one videos. I am using AVExportSession
to export merged video. I am also displaying progress bar for exporting video. It is running correctly most of times.
The issue occurs when we lock the screen or put application in background mode. This time if exporting is in process, it immediately fails after putting application in background mode. I have also tried to use background task. Check below code.
bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
// Clean up any unfinished task business by marking where you.
// stopped or ending the task outright.
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
But this does not seem to work. What am I doing wrong? Any help would be appreciated.
回答1:
Sadly, since AVAssetExportSession
uses the gpu to do some of it's work, it cannot run in the background if you are using an AVVideoComposition
.
来源:https://stackoverflow.com/questions/16439317/avexportsession-to-run-in-background