tanersener/flutter-ffmpeg

the time in StatisticsCallback is bigger than video duration

saviourdog opened this issue · 7 comments

Description
the time in StatisticsCallback is bigger than video duration

Expected behavior
the video duration is 2:29,and the time of last line of output should be 2:29
image
image

Current behavior
callback`s duration bigger than video duration
image

my code,best regards!
image

I don't get what your screenshots show? Can you write them in text please?

sorry,my bad

final FlutterFFmpeg ffm = FlutterFFmpeg();
    final FlutterFFprobe ffp = FlutterFFprobe();
    FlutterFFmpegConfig ffc = FlutterFFmpegConfig();
    final doc = await getApplicationDocumentsDirectory();
    var dir = Directory(doc.path + '/cover');
    if (!dir.existsSync()) {
      dir.createSync();
    }
    if (tmpVideo != null && covers.value.length == 0) {
      var info = await ffp.getMediaInformation(tmpVideo.path);
      var duration = info.getMediaProperties()['duration'];
      print("info.getMediaProperties()['duration'] $duration");
      ffm
          .execute(
              '-i ${tmpVideo.path} -r ${10 / double.parse(duration)} -vf "crop=ih*1.8:ih:(iw-ih*1.8)/2:0" ${dir.path}/%2d.jpg')
          .then((rc) {
        print("FFmpeg process exited with rc $rc");
        covers.value = dir.listSync().toList();
      });
      ffc.enableStatisticsCallback((statistics) {
        print(
            "Statistics: executionId: ${statistics.executionId}, time: ${statistics.time}, size: ${statistics.size}, bitrate: ${statistics.bitrate}, speed: ${statistics.speed}, videoFrameNumber: ${statistics.videoFrameNumber}, videoQuality: ${statistics.videoQuality}, videoFps: ${statistics.videoFps}");
      });
    }

2:29 is the duration of your input video. And the time reported by StatisticsCallback is the time calculated for the output of your command. They cannot always be the same. Output can be longer or shorter depending on your command and the options used.

In your case, the time value coming from StatisticsCallback is bigger than the time of your input video. But I also see that your output is not a video, it is a series of images. So, time for your command won't have a meaningful value. You should try using other fields returned from StatisticsCallback.

thank you a lot

so this command can not get progress,right?

No, ffmpeg can not give you the progress. You need to calculate it yourself using statistics.

thanks a lot