当视频处理过程中用户从任务管理器中关闭应用程序然后停止处理时,就会出现问题。
我正在使用FFMpeg在android中进行视频文件处理,它工作正常,但是当我在从任务管理器处理过程中关闭应用程序时,视频处理已停止工作,即使我在工作管理器中添加了所有工作。
@Override public Result doWork() { shellCommand = new ShellCommand(); ffmpegBinary = new String[] { FileUtils.getFFmpeg(context).getAbsolutePath() }; command = concatenate(ffmpegBinary, command); CommandResult commandResult = getCommandResult(command); if (command`enter code here`Result.success) { onSuccess(videoPath); } else { onFailure(videoPath); } } //getCommandResult private CommandResult getCommandResult(String[] command) { try { process = shellCommand.run(command, null); if (process == null) { return CommandResult.getDummyFailureResponse(); } checkAndUpdateProcess(); return CommandResult.getOutputFromProcess(process); } catch(Exception e) {} finally { Util.destroyProcess(process); }`enter code here` return CommandResult.getDummyFailureResponse(); }
据我所知,当应用程序从后台关闭时,父进程会销毁它并同时销毁其所有子进程,FFMpeg正在使用android进程执行命令并在视频处理过程中检查视频文件状态。
期待着听到您的意见。谢谢