diff mbox

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

Message ID 1513238450-5493-1-git-send-email-mymoeyard@gmail.com
State Superseded
Headers show

Commit Message

mymoeyard@gmail.com Dec. 14, 2017, 8 a.m. UTC
From: wu zhiqiang <mymoeyard@gmail.com>

When using concat protocal, start from middle of file will generate non-zero wrap reference. If seek to time less than the wrap reference, wrap control will be triggered and generate wrong wrapped timestamp.
Copy wrap related stream properties when reading header can fix this problem.

Signed-off-by: wu zhiqiang <mymoeyard@gmail.com>
---
 libavformat/concatdec.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Steven Liu Dec. 14, 2017, 8:20 a.m. UTC | #1
2017-12-14 16:00 GMT+08:00  <mymoeyard@gmail.com>:
> From: wu zhiqiang <mymoeyard@gmail.com>
>
> When using concat protocal, start from middle of file will generate non-zero wrap reference. If seek to time less than the wrap reference, wrap control will be triggered and generate wrong wrapped timestamp.
> Copy wrap related stream properties when reading header can fix this problem.
>
> Signed-off-by: wu zhiqiang <mymoeyard@gmail.com>
> ---
>  libavformat/concatdec.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
> index 0e189012ad..e933888661 100644
> --- a/libavformat/concatdec.c
> +++ b/libavformat/concatdec.c
> @@ -188,6 +188,11 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
>      st->time_base           = source_st->time_base;
>      st->sample_aspect_ratio = source_st->sample_aspect_ratio;
>
> +    /* Fix wrap control problem */
> +    st->pts_wrap_bits       = source_st->pts_wrap_bits;
> +    st->pts_wrap_behavior   = source_st->pts_wrap_behavior;
> +    st->pts_wrap_reference  = source_st->pts_wrap_reference;
> +
>      av_dict_copy(&st->metadata, source_st->metadata, 0);
>      return 0;
>  }
> --
> 2.15.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


LGTM


Thanks

Steven
Michael Niedermayer Dec. 14, 2017, 4:04 p.m. UTC | #2
On Thu, Dec 14, 2017 at 03:00:50AM -0500, mymoeyard@gmail.com wrote:
> From: wu zhiqiang <mymoeyard@gmail.com>
> 
> When using concat protocal, start from middle of file will generate non-zero wrap reference. If seek to time less than the wrap reference, wrap control will be triggered and generate wrong wrapped timestamp.
> Copy wrap related stream properties when reading header can fix this problem.
> 
> Signed-off-by: wu zhiqiang <mymoeyard@gmail.com>
> ---
>  libavformat/concatdec.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
> index 0e189012ad..e933888661 100644
> --- a/libavformat/concatdec.c
> +++ b/libavformat/concatdec.c
> @@ -188,6 +188,11 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
>      st->time_base           = source_st->time_base;
>      st->sample_aspect_ratio = source_st->sample_aspect_ratio;
>  
> +    /* Fix wrap control problem */
> +    st->pts_wrap_bits       = source_st->pts_wrap_bits;
> +    st->pts_wrap_behavior   = source_st->pts_wrap_behavior;
> +    st->pts_wrap_reference  = source_st->pts_wrap_reference;

why does this not use avpriv_set_pts_info() ?


[...]
Liu Steven Dec. 14, 2017, 10:31 p.m. UTC | #3
> 在 2017年12月15日,上午12:04,Michael Niedermayer <michael@niedermayer.cc> 写道:
> 
> On Thu, Dec 14, 2017 at 03:00:50AM -0500, mymoeyard@gmail.com wrote:
>> From: wu zhiqiang <mymoeyard@gmail.com>
>> 
>> When using concat protocal, start from middle of file will generate non-zero wrap reference. If seek to time less than the wrap reference, wrap control will be triggered and generate wrong wrapped timestamp.
>> Copy wrap related stream properties when reading header can fix this problem.
>> 
>> Signed-off-by: wu zhiqiang <mymoeyard@gmail.com>
>> ---
>> libavformat/concatdec.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>> 
>> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
>> index 0e189012ad..e933888661 100644
>> --- a/libavformat/concatdec.c
>> +++ b/libavformat/concatdec.c
>> @@ -188,6 +188,11 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
>>     st->time_base           = source_st->time_base;
>>     st->sample_aspect_ratio = source_st->sample_aspect_ratio;
>> 
>> +    /* Fix wrap control problem */
>> +    st->pts_wrap_bits       = source_st->pts_wrap_bits;
>> +    st->pts_wrap_behavior   = source_st->pts_wrap_behavior;
>> +    st->pts_wrap_reference  = source_st->pts_wrap_reference;
> 
> why does this not use avpriv_set_pts_info() ?

Add st->pts_wrap_behavior   = source_st->pts_wrap_behavior; and st->pts_wrap_reference  = source_st->pts_wrap_reference; into avpriv_set_pts_info?
or only replace avpriv_set_pts_info st->pts_wrap_bits       = source_st->pts_wrap_bits; here?

Thanks

Steven
> 
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> There will always be a question for which you do not know the correct answer.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
mymoeyard@gmail.com Dec. 15, 2017, 5:04 a.m. UTC | #4
I see pts_wrap_bits must be modified in this function.   I re-submit  the
new patch, only replace avpriv_set_pts_info st->pts_wrap_bits       =
source_st->pts_wrap_bits by avpriv_set_pts_info.

Liu Steven <lq@chinaffmpeg.org> 于 2017年12月15日周五 上午6:30写道:

>
> > 在 2017年12月15日,上午12:04,Michael Niedermayer <michael@niedermayer.cc> 写道:
> >
> > On Thu, Dec 14, 2017 at 03:00:50AM -0500, mymoeyard@gmail.com wrote:
> >> From: wu zhiqiang <mymoeyard@gmail.com>
> >>
> >> When using concat protocal, start from middle of file will generate
> non-zero wrap reference. If seek to time less than the wrap reference, wrap
> control will be triggered and generate wrong wrapped timestamp.
> >> Copy wrap related stream properties when reading header can fix this
> problem.
> >>
> >> Signed-off-by: wu zhiqiang <mymoeyard@gmail.com>
> >> ---
> >> libavformat/concatdec.c | 5 +++++
> >> 1 file changed, 5 insertions(+)
> >>
> >> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
> >> index 0e189012ad..e933888661 100644
> >> --- a/libavformat/concatdec.c
> >> +++ b/libavformat/concatdec.c
> >> @@ -188,6 +188,11 @@ static int copy_stream_props(AVStream *st,
> AVStream *source_st)
> >>     st->time_base           = source_st->time_base;
> >>     st->sample_aspect_ratio = source_st->sample_aspect_ratio;
> >>
> >> +    /* Fix wrap control problem */
> >> +    st->pts_wrap_bits       = source_st->pts_wrap_bits;
> >> +    st->pts_wrap_behavior   = source_st->pts_wrap_behavior;
> >> +    st->pts_wrap_reference  = source_st->pts_wrap_reference;
> >
> > why does this not use avpriv_set_pts_info() ?
>
> Add st->pts_wrap_behavior   = source_st->pts_wrap_behavior; and
> st->pts_wrap_reference  = source_st->pts_wrap_reference; into
> avpriv_set_pts_info?
> or only replace avpriv_set_pts_info st->pts_wrap_bits       =
> source_st->pts_wrap_bits; here?
>
> Thanks
>
> Steven
> >
> >
> > [...]
> > --
> > Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > There will always be a question for which you do not know the correct
> answer.
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 0e189012ad..e933888661 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -188,6 +188,11 @@  static int copy_stream_props(AVStream *st, AVStream *source_st)
     st->time_base           = source_st->time_base;
     st->sample_aspect_ratio = source_st->sample_aspect_ratio;
 
+    /* Fix wrap control problem */
+    st->pts_wrap_bits       = source_st->pts_wrap_bits;
+    st->pts_wrap_behavior   = source_st->pts_wrap_behavior;
+    st->pts_wrap_reference  = source_st->pts_wrap_reference;
+
     av_dict_copy(&st->metadata, source_st->metadata, 0);
     return 0;
 }