ffmpeg-kit icon indicating copy to clipboard operation
ffmpeg-kit copied to clipboard

The executeAsync async method is not executed successfully

Open dancb10 opened this issue 2 years ago • 1 comments

I have the following code in my flutter app which works when executing the FFmpegKit with synchronous method

final command =
        "'-y' '-i' '$attachmentPath' '-c:v' 'h264' '-b:v' '500k' '-c:a' 'aac' '-b:a' '128k' '$compressedAttachment'";

    FFmpegKit.execute(command).then((session) async {
      var logs = await session.getAllLogs();
      var stack = await session.getFailStackTrace();
      var statistics = await session.getAllStatistics();
      var code = await session.getReturnCode();

      print(code); // success
    });

So the above code works, I can see the compressed file and everything is ok. Now, I would like to execute multiple compress executions in parallel by using the async method.

try {
     final command =
        "'-y' '-i' '$attachmentPath' '-c:v' 'h264' '-b:v' '500k' '-c:a' 'aac' '-b:a' '128k' '$compressedAttachment'";

      var session = await FFmpegKit.executeAsync(command);
      var logs = await session.getAllLogs();
      var stack = await session.getFailStackTrace();
      var statistics = await session.getAllStatistics();
      var code = await session.getReturnCode();

      print(code); // null
    } catch (e) {
      print("Error executing FFmpeg command: $e");
    }

I don't know what's happening, I've tried in different ways, btw the example shown in your docs does not work in flutter with the executeAsync method. Could you please tell me if this is a bug or I'm doing something wrong.

Below is the code from your docs which doesn't work "The argument type 'void Function(Log)' can't be assigned to the parameter type 'void Function(Log)?"

FFmpegKit.executeAsync('-i file1.mp4 -c:v mpeg4 file2.mp4', (Session session) async {

  // CALLED WHEN SESSION IS EXECUTED

}, (Log log) {

  // CALLED WHEN SESSION PRINTS LOGS

}, (Statistics statistics) {

  // CALLED WHEN SESSION GENERATES STATISTICS

});

dancb10 avatar Apr 02 '24 11:04 dancb10

Did you look at the flutter test applications under the ffmpeg kit test repo? They show how executeAsync can be called in different ways.

See this one to execute multiple commands at the same time.

tanersener avatar Apr 10 '24 20:04 tanersener

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 10 '24 01:06 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Jun 17 '24 01:06 github-actions[bot]