]> git.sesse.net Git - ffmpeg/commitdiff
lavf/utils: support duration estimate method dump
authorJun Zhao <barryjzhao@tencent.com>
Sun, 29 Sep 2019 03:58:43 +0000 (11:58 +0800)
committerJun Zhao <barryjzhao@tencent.com>
Mon, 30 Sep 2019 02:08:45 +0000 (10:08 +0800)
add new function duration_estimate_name to dump duration estimate
method, it's will help to debug some duration issue.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
libavformat/utils.c

index 112d19b86ef8e25578d30c0005a38cce65f64295..60f0229adc43c6dbfbf2f6202f2680c8b0603686 100644 (file)
@@ -2934,6 +2934,18 @@ skip_duration_calc:
     }
 }
 
+/* 1:1 map to AVDurationEstimationMethod */
+static const char *duration_name[] = {
+    [AVFMT_DURATION_FROM_PTS]     = "pts",
+    [AVFMT_DURATION_FROM_STREAM]  = "stream",
+    [AVFMT_DURATION_FROM_BITRATE] = "bit rate",
+};
+
+static const char *duration_estimate_name(enum AVDurationEstimationMethod method)
+{
+    return duration_name[method];
+}
+
 static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
 {
     int64_t file_size;
@@ -2979,9 +2991,10 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
                        (double) st->duration   * av_q2d(st->time_base));
         }
         av_log(ic, AV_LOG_TRACE,
-                "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64" kb/s\n",
+                "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n",
                 (double) ic->start_time / AV_TIME_BASE,
                 (double) ic->duration   / AV_TIME_BASE,
+                duration_estimate_name(ic->duration_estimation_method),
                 (int64_t)ic->bit_rate / 1000);
     }
 }