diff mbox series

[FFmpeg-devel,2/3] lavf/utils: fix start_time dump when the value is AV_NOPTS_VALUE

Message ID 1589700286-4129-2-git-send-email-mypopydev@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] lavc/aac_ac3_parser: improve the raw AAC file bit rate calculation
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Jun Zhao May 17, 2020, 7:24 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

The command:
ffprobe -show_format -i ../fate-suite/aac/foo.aac -loglevel 99 will
dump the trace message as follow when start_time is AV_NOPTS_VALUE
[aac @ 0x55bf8e1f3dc0] stream 0: start_time: -326791809695.818 duration: 2.174
[aac @ 0x55bf8e1f3dc0] format: start_time: -9223372036854.775 duration: 2.174 bitrate=120 kb/s

after this fix, will dump the start_time with "N/A".

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/utils.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index e6158d8..d7fdd72 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2983,11 +2983,24 @@  static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
         AVStream av_unused *st;
         for (i = 0; i < ic->nb_streams; i++) {
             st = ic->streams[i];
-            if (st->time_base.den)
+            if (st->time_base.den) {
+                if (st->start_time == AV_NOPTS_VALUE)
+                    av_log(ic, AV_LOG_TRACE, "stream %d: start_time: N/A duration: %0.3f\n", i,
+                           (double) st->duration   * av_q2d(st->time_base));
+                else
                 av_log(ic, AV_LOG_TRACE, "stream %d: start_time: %0.3f duration: %0.3f\n", i,
                        (double) st->start_time * av_q2d(st->time_base),
                        (double) st->duration   * av_q2d(st->time_base));
+            }
         }
+
+        if (ic->start_time == AV_NOPTS_VALUE)
+            av_log(ic, AV_LOG_TRACE,
+                   "format: start_time: N/A duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n",
+                   (double) ic->duration   / AV_TIME_BASE,
+                   duration_estimate_name(ic->duration_estimation_method),
+                   (int64_t)ic->bit_rate / 1000);
+        else
         av_log(ic, AV_LOG_TRACE,
                 "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n",
                 (double) ic->start_time / AV_TIME_BASE,