Flutter ffmpeg_kit_flutter: get FFmpegKit.executeAsync error

Viewed 512

I have prepared a test program to run FFMPEG command and it successfully run -i "/data/user/0/com.example.test/cache/file_picker/test.mp4" -c:v mpeg4 "/data/user/0/com.example.test/cache/test-1639310478143.mp4" command. This is just to ensure that ffmpeg_kit_flutter was loaded properly and all permissions has been obtained.

But, I have problem executing -i "source.mp4" -vf fps=30 "thumb%03d.jpg" -hide_banner command. The command itself is working well when I run it on windows, for example:

md frame1
ffmpeg -i "test.mp4" -vf fps=30 frame1/thumb%%04d.jpg -hide_banner

(note: double % is to escape the % in windows batch file)

This is what I do in flutter on android:

  1. Create temporary folder.
  2. Execute:
    String command = '-i "/data/user/0/com.example.test/cache/file_picker/test.mp4" -vf fps=30 "/data/user/0/com.example.test/cache/tmp-1639309602536/thumb%03d.jpg" -hide_banner';
    FFmpegKit.executeAsync(command, (session) async {
        final returnCode = await session.getReturnCode();
        if (ReturnCode.isSuccess(returnCode)) {
            //ok
        } else if (ReturnCode.isCancel(returnCode)) {
            //cancelled
        } else {
            //error
        }
    });

The proses is not working (always going to the error part). My questions are:

  1. What is the difference between running that command on windows and android? Why it works on windows but not working on android?
  2. How can I get the explanation about any FFMPEG error? In my case, I only know that wasn't working, but I have no clue why.
1 Answers

Using Space Character In a Command String

execute() and executeAsync() methods in FFmpegKit and FFprobeKit splits a command into arguments by using the space character as a delimiter. If one of your command parameters includes a space character inside then it will be split into two parameters and your command execution will fail. To prevent that, wrap that parameter using single or double quotes. Wrapping will prevent the parameter from being split.

Alternatively, you can split your command into arguments yourself and call one of the overloaded executeWithArguments()/executeWithArgumentsAsync() methods that accept arguments array.

Related