diff mbox

[FFmpeg-devel,V2] avformat/concat: Fix wrong wrapped timestamp

Message ID 20171230113008.GA3546744@phare.normalesup.org
State New
Headers show

Commit Message

Nicolas George Dec. 30, 2017, 11:30 a.m. UTC
Wu Zhiqiang (2017-12-30):
> The command to  generate sample video:
> 
> ffmpeg -f lavfi -i testsrc=duration=120  -c:v h264 -profile:v high -level:v
> 10 -pix_fmt yuv420p -r 30 -g 30 -c:a aac test.flv
> echo -e "file test.flv\nduration 120" > playlist
> ffplay -f concat playlist -ss 90 -max_ts_probe 0
> 
> then seek to time before 30s , the result timestamp  is huge and
> print:"Invalid timestamps stream"

Thanks. I think I understand the problem: it is not that the timestamps
are not unwrapped, it is that they are unwrapped twice, because for some
reason lavf defaults to parameters tuned for MPEG.

See the attached patch.

Regards,

Comments

mymoeyard@gmail.com Dec. 30, 2017, 3:27 p.m. UTC | #1
2017年12月30日 下午7:30,"Nicolas George" <george@nsup.org>写道:

Wu Zhiqiang (2017-12-30):
> The command to  generate sample video:
>
> ffmpeg -f lavfi -i testsrc=duration=120  -c:v h264 -profile:v high
-level:v
> 10 -pix_fmt yuv420p -r 30 -g 30 -c:a aac test.flv
> echo -e "file test.flv\nduration 120" > playlist
> ffplay -f concat playlist -ss 90 -max_ts_probe 0
>
> then seek to time before 30s , the result timestamp  is huge and
> print:"Invalid timestamps stream"

Thanks. I think I understand the problem: it is not that the timestamps
are not unwrapped, it is that they are unwrapped twice, because for some
reason lavf defaults to parameters tuned for MPEG.

See the attached patch.

Regards,

--
  Nicolas George
Nicolas George Dec. 31, 2017, 10:11 a.m. UTC | #2
Wu Zhiqiang (2017-12-30):
> Thanks for the patch, it works fine to me.
> Disable is good enough to prevent unnecessary wrap control.

Thanks for the testing. Patch pushed.

Regards,
diff mbox

Patch

From 9f24fe25cddabc0b0dc1a60d1789ea7feaa125f7 Mon Sep 17 00:00:00 2001
From: Nicolas George <george@nsup.org>
Date: Sat, 30 Dec 2017 12:17:08 +0100
Subject: [PATCH] lavf/concatdec: properly init streams timestamp parameters.

pts_wrap_bits defaults to 33 (like MPEG), that causes valid
timestamps to be unwrapped and become invalid.
Inspired by a patch by Wu Zhiqiang <mymoeyard@gmail.com>.

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavformat/concatdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 0e189012ad..bd5174ada2 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -185,8 +185,8 @@  static int copy_stream_props(AVStream *st, AVStream *source_st)
         return ret;
     st->r_frame_rate        = source_st->r_frame_rate;
     st->avg_frame_rate      = source_st->avg_frame_rate;
-    st->time_base           = source_st->time_base;
     st->sample_aspect_ratio = source_st->sample_aspect_ratio;
+    avpriv_set_pts_info(st, 64, source_st->time_base.num, source_st->time_base.den);
 
     av_dict_copy(&st->metadata, source_st->metadata, 0);
     return 0;
-- 
2.15.1