AVEExportSession 在后台运行 [英] AVExportSession to run in background

查看:45
本文介绍了AVEExportSession 在后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款需要合并多个视频的应用程序.我正在使用 AVExportSession 导出合并的视频.我还显示导出视频的进度条.大多数情况下它都能正常运行.

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.

推荐答案

遗憾的是,由于 AVAssetExportSession 使用 gpu 来完成它的一些工作,如果您使用 <代码>AVVideoComposition.

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.

这篇关于AVEExportSession 在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆