From: Jun Zhao <barryjz...@tencent.com>

add duration estimate method trace, it's can help to some duration
issue trace or debug.

Signed-off-by: Jun Zhao <barryjz...@tencent.com>
---
 libavformat/utils.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index c0ccd8c..8620c6f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2977,6 +2977,16 @@ static void estimate_timings(AVFormatContext *ic, 
int64_t old_offset)
     {
         int i;
         AVStream av_unused *st;
+        const char *duration_method;
+        struct duration_mode {
+            enum AVDurationEstimationMethod mode;
+            const char *name; ///< short name for the duration estimation 
method
+        };
+        struct duration_mode duration_modes[] = {
+            { AVFMT_DURATION_FROM_PTS,    "pts"       },
+            { AVFMT_DURATION_FROM_STREAM, "stream"    },
+            { AVFMT_DURATION_FROM_BITRATE,"bit rate"  },
+        };
         for (i = 0; i < ic->nb_streams; i++) {
             st = ic->streams[i];
             if (st->time_base.den)
@@ -2984,10 +2994,14 @@ static void estimate_timings(AVFormatContext *ic, 
int64_t old_offset)
                        (double) st->start_time * av_q2d(st->time_base),
                        (double) st->duration   * av_q2d(st->time_base));
         }
+        for (i = 0; i < FF_ARRAY_ELEMS(duration_modes); i++)
+            if (ic->duration_estimation_method == duration_modes[i].mode)
+                duration_method = duration_modes[i].name;
         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_method,
                 (int64_t)ic->bit_rate / 1000);
     }
 }
-- 
1.7.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to