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

Joakim Plate elupus at ecce.se
Sat Dec 14 11:53:57 CET 2013


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