[FFmpeg-devel] [PATCH] MPEG-TS/-PS : better probing for duration and start-time for all streams in a container

Michael Niedermayer michaelni at gmx.at
Sun May 25 21:27:00 CEST 2014


On Thu, May 22, 2014 at 05:14:28PM +0000, Gaullier Nicolas wrote:
> Please see below the patch for the two remaining points :
> 1- the duration (take into account the pkt->duration of the last frame)
> 2- the start_time
> 
> For the first one, as you noticed there was previously a DTS order error. After investigation, it appeared that it was related to the retry algorithm : the retry makes the stream to be played in a reverse order, thus the warning. If you disable retry by setting a high value for DURATION_MAX_READ_SIZE, the problem disappeared. Thus, I decided to mask this warning : simply by reset last_dts_for_order_check.
> For the second one in "update_initial_timestamps", I have not changed anything since I think you did not highlight any particular issue with it
> 
> Nicolas Gaullier
> ----
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 8e79177..8cd7ea3 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1033,6 +1033,13 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
>      int64_t shift;
>      int i, delay;
>  
> +    if (pts != AV_NOPTS_VALUE) {
> +        if (st->start_time == AV_NOPTS_VALUE) {
> +            st->start_time = pts;
> +        } else {
> +            st->start_time = FFMIN(pts,st->start_time);
> +        }
> +    }
>      if (st->first_dts != AV_NOPTS_VALUE ||
>          dts           == AV_NOPTS_VALUE ||
>          st->cur_dts   == AV_NOPTS_VALUE ||
> @@ -1070,9 +1077,6 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
>              pktl->pkt.dts = select_from_pts_buffer(st, pts_buffer, pktl->pkt.dts);
>          }
>      }
> -
> -    if (st->start_time == AV_NOPTS_VALUE)
> -        st->start_time = pts;

there are 2 lines in this function which can update the start time
the second uses only a AV_NOPTS_VALUE check and no min, i suspect
thats wrong
also moving this before while the 2nd is after is_relative()
correction, feels wrong

iam not sure if these are the only issues, ill test it more
throughout once these 2 are corrected

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140525/9d554f96/attachment.asc>


More information about the ffmpeg-devel mailing list