[FFmpeg-devel] [PATCH 3/3] [RFC] mpegts: Support seeking based on stream timestamps.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Sep 28 14:12:36 CEST 2014


On Sun, Sep 28, 2014 at 10:15:51AM +0200, wm4 wrote:
> On Sun, 21 Sep 2014 10:17:16 +0100
> Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index 3434341..c04e156 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -2659,6 +2659,12 @@ void ff_mpegts_parse_close(MpegTSContext *ts)
> >      av_free(ts);
> >  }
> >  
> > +static int mpegts_read_seek(AVFormatContext *s, int stream_index,
> > +                            int64_t ts, int flags)
> > +{
> > +    return avio_seek_time(s->pb, stream_index, ts, flags);
> > +}
> > +
> >  AVInputFormat ff_mpegts_demuxer = {
> >      .name           = "mpegts",
> >      .long_name      = NULL_IF_CONFIG_SMALL("MPEG-TS (MPEG-2 Transport Stream)"),
> > @@ -2668,6 +2674,7 @@ AVInputFormat ff_mpegts_demuxer = {
> >      .read_packet    = mpegts_read_packet,
> >      .read_close     = mpegts_read_close,
> >      .read_timestamp = mpegts_get_dts,
> > +    .read_seek      = mpegts_read_seek,
> >      .flags          = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
> >      .priv_class     = &mpegts_class,
> >  };
> > @@ -2680,6 +2687,7 @@ AVInputFormat ff_mpegtsraw_demuxer = {
> >      .read_packet    = mpegts_raw_read_packet,
> >      .read_close     = mpegts_read_close,
> >      .read_timestamp = mpegts_get_dts,
> > +    .read_seek      = mpegts_read_seek,
> >      .flags          = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
> >      .priv_class     = &mpegtsraw_class,
> >  };
> 
> IMO this is not a good idea. Seeking should seek the stream to a
> timestamp; but the demuxer will output mismatching timestamps with a
> different offset!

Oh well.
This is actually what makes it not work in MPlayer.
Plus I think it's a bug that MPlayer ends up calling the demuxer
seek code in the first place.
So thanks for making me think once more.
I still think all this is a mess that needs to be improved
on _FFmpeg_ side, but I am not quite sure how anymore.


More information about the ffmpeg-devel mailing list