tanersener / flutter-ffmpeg

FFmpeg plugin for Flutter. Not maintained anymore. Superseded by FFmpegKit.
GNU Lesser General Public License v3.0
644 stars 132 forks source link

the time in StatisticsCallback is bigger than video duration #291

Closed saviourdog closed 3 years ago

saviourdog commented 3 years ago

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

tanersener commented 3 years ago

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

saviourdog commented 3 years ago

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}");
      });
    }
tanersener commented 3 years ago

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.

saviourdog commented 3 years ago

thank you a lot

saviourdog commented 3 years ago

so this command can not get progress,right?

tanersener commented 3 years ago

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

saviourdog commented 3 years ago

thanks a lot