[FFmpeg-devel] seeking in ts (was: mpegvideo_parser outputs incomplete frames)
Sun Sep 2 23:33:02 CEST 2007
> On Thu, Aug 30, 2007 at 10:16:57PM -0000, Wolfram Gloger wrote:
> > Yes it should, but seeking in mpeg-ts is currently broken for me at
> > least for frame copying, because first_dts isn't updated after a seek
> > and that leads to oscillating timestamp problems. Please consider the
> > appended patch.
> updated after a seek !?
> what do you want to update, first_dts is the first dts, that doesnt change
> after a seek
Well I want/need to call av_find_stream_info() after the seek (stream
parameters might have changed a lot after a seek in ts), and at the
end of that we have
(libavformat/utils.c:1561) so now cur_dts is _way_ off if we have read
packets before at some other position in the stream. Also if the seek
function for some reason would set cur_dts to AV_NOPTS_VALUE (say we
have specified a byte seek), the first_dts mechanism could then be
used just like if at the start of the stream.
> > @@ -1342,18 +1386,20 @@
> > st=3D s->streams[stream_index];
> > =20
> > /* first, we try the format specific seek */
> > - if (s->iformat->read_seek)
> > - ret =3D s->iformat->read_seek(s, stream_index, timestamp, flags);
> > - else
> > - ret =3D -1;
> > + if (!s->iformat->read_seek ||
> > + (ret =3D s->iformat->read_seek(s, stream_index, timestamp, flags)) < 0)
> > + ret =3D s->iformat->read_timestamp ?
> > + av_seek_frame_binary(s, stream_index, timestamp, flags) :
> > + av_seek_frame_generic(s, stream_index, timestamp, flags);
> this is a unreadable mess and contains tabs
Sorry about the tabs -- and I couldn't see a more elegant way of
providing a single exit point to avoid duplication of the for() loop..
More information about the ffmpeg-devel