Video Processing in background with work manager using ffmpeg
Asked Answered
D

0

6

The problem comes when during the video processing user closes the application himself from the task manager then its processing stops.

I am working on video file processing in android using FFMpeg, which is working perfectly but when I do close the application during processing from task manager then video processing has stopped working even I added all the work in work manager.

    @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);
        }
        return CommandResult.getDummyFailureResponse();
    }

As far as I can tell, when the application closes from the background then the parent process destroys it and is destroying all of its sub-process too, FFMpeg is using the android process to execute the command and check the video file status during video processing.

Looking forward to hear from you. Thanks

Dissogeny answered 27/6, 2019 at 7:7 Comment(4)
include the link for the library. naser joooonGaptoothed
If the application is Force stopped, there's little that WorkManager can do as that action stops all the work till the app is restarted by the user.Musjid
As this answer explains, this behavior may happen on some devices, but cannot be relied upon.Dingman
Have you found any solution yet? Please let me know @Naseer AttariProlongation

© 2022 - 2024 — McMap. All rights reserved.