[FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp
Wu Zhiqiang
mymoeyard at gmail.com
Fri Dec 29 19:33:13 EET 2017
2017年12月30日 上午12:30,"Nicolas George" <george at nsup.org>写道:
Wu Zhiqiang (2017-12-30):
> Normally pts_wrap_reference is based on the first packet when calling
> ff_read_packet,
> which will call function update_wrap_reference , in libavformat/utils
line
> 734:
>
> if (ref == AV_NOPTS_VALUE)
> ref = pkt->pts;
> if (st->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >=
63
> || ref == AV_NOPTS_VALUE || !s->correct_ts_overflow)
> return 0;
> ref &= (1LL << st->pts_wrap_bits)-1;
>
> // reference time stamp should be 60 s before first time stamp
> pts_wrap_reference = ref - av_rescale(60, st->time_base.den,
> st->time_base.num);
>
> Because concat_read_header and concat_seek do not call ff_read_packet
and
> open_file does not copy pts_wrap_reference,
> it is constant value during playing.
>
> If demuxing packets like avformat_open_input => avformat_seek_file =>
> av_read_frame and seek time is larger than 60s,
> the constant reference time will be positive value and not indicate the
> normal wrap margin.
>
> Then seeking to time before pts_wrap_reference may generate huge
timestamp,
> which not expected.
Thanks for explaining, but it still does not address my concern. I
probably explained it badly. Let me try to rephrase.
When an application is reading directly from a file, if I understand
correctly, here is what happens:
1. file contains wrapped timestamps;
2. demuxer sets wrapping_bits to enable timestamps correction;
3. demuxer outputs packets with non-monotonic timestamps;
4. lavf sees non-monotonic timestamps;
5. lavf detects wrapping reference;
6. lavf fixes non-monotonic timestamps;
7. lavf returns packets with monotonic timestamps;
8. application sees packets with monotonic timestamps;
9. application has nothing to do at all about wrapping.
Is it right?
The concat demuxer behaves like any application. Therefore, I can
copy-paste and rename:
1. file contains wrapped timestamps;
2. slave demuxer sets wrapping_bits to enable timestamps correction;
3. slave demuxer outputs packets with non-monotonic timestamps;
4. lavf for slave demuxer sees non-monotonic timestamps;
5. lavf for slave demuxer detects wrapping reference;
6. lavf for slave demuxer fixes non-monotonic timestamps;
7. lavf for slave demuxer returns packets with monotonic timestamps;
8. concat sees packets with monotonic timestamps;
9. concat has nothing to do at all about wrapping.
And it should still be right. Note the conclusion: concat has nothing to
do at all about wrapping.
I will try to rephrase yet another way:
Wrapped timestamps should be de-wrapped even before concat sees them,
and thus no de-wrapping should be necessary after concat.
Regards,
--
Nicolas George
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
But how to decide wrap margin that concat see?
Though monotonic timestamp is always ok,
I do not want that sub-demuxer see unwrapped timestamp but concat see
wrapped one .
Or sub-demuxer disable wrap correction but concat enable it.
Thanks
More information about the ffmpeg-devel
mailing list