[FFmpeg-devel] [PATCH 1/1] mpegts: speed up find_stream_info for mpegts

Joakim Plate elupus at ecce.se
Sat Dec 14 12:04:11 CET 2013


Hi,

I think i've sent something similar to this before. Two objections were:
1. We will not find multiple conflicting PMT's in the stream (cat file.a
file.b > file.c) during find_stream_info. We will just find the first one.
Imho that is fully valid. The next PMT should be found during read of the
file.
2. Removing NOHEADER on the file like this was not in it's original design
Havn't seen any side effects of that yet. Seem alright to me.
3. auto_guess will be somewhat mute for ffprobe, since no additional
streams will be added during find_stream_info.
Maybe somewhat problematic.


It does however make the mpegts demuxer usable for live streaming and
channel changes, which was not the case before. Before the patch ALL
streams would take 5 seconds to tune since that is the time limit for
find_stream_info. This affected rtsp playback as well.

To me this behavior should be the default behavior at least.




On Sat, Dec 14, 2013 at 11:53 AM, Joakim Plate <elupus at ecce.se> wrote:

> This disable NOHEADER after finding PMT, find_stream_info
> will always exhaust probe size for mpegts since this flag
> is set.
>
> This is very problematically for live streams since read speed
> will be limited. rtsp, udp and any protocol streaming a live
> mpegts will have dramatically faster startup time.
> ---
>  libavformat/mpegts.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index d67c63a..3b737c6 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -1590,6 +1590,9 @@ static void pmt_cb(MpegTSFilter *filter, const
> uint8_t *section, int section_len
>      if (!ts->stream->nb_streams)
>          ts->stop_parse = 2;
>
> +    // stop find_stream_info from waiting for more streams
> +    ts->stream->ctx_flags &= ~AVFMTCTX_NOHEADER;
> +
>      for(;;) {
>          st = 0;
>          pes = NULL;
> @@ -2160,6 +2163,8 @@ static int mpegts_read_header(AVFormatContext *s)
>      ts->stream = s;
>      ts->auto_guess = 0;
>
> +    s->ctx_flags |= AVFMTCTX_NOHEADER;
> +
>      if (s->iformat == &ff_mpegts_demuxer) {
>          /* normal demux */
>
> @@ -2177,7 +2182,6 @@ static int mpegts_read_header(AVFormatContext *s)
>
>          av_dlog(ts->stream, "tuning done\n");
>
> -        s->ctx_flags |= AVFMTCTX_NOHEADER;
>      } else {
>          AVStream *st;
>          int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l;
> --
> 1.8.2
>
>


More information about the ffmpeg-devel mailing list