[FFmpeg-devel] [RFC][PATCH] mpeg demuxer: discover streams on open

Andrey Utkin andrey.krieger.utkin at gmail.com
Mon Aug 20 17:10:12 CEST 2012


This is trial fix, i am far from being sure i did it the right way.
The problem i try to solve is that mpeg (mpegps) demuxer does not try to discover any elementary streams at read_header().
The intention is to have VOB file elementary streams recognized without avformat_find_stream_info(), which takes like 10x more time.

---8<---
---
 libavformat/mpeg.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 54125ae..fa44bf0 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -112,6 +112,7 @@ static int mpegps_read_header(AVFormatContext *s)
     const char *sofdec = "Sofdec";
     int v, i = 0;
     int64_t last_pos = avio_tell(s->pb);
+    AVPacket pkt = { 0, };
 
     m->header_state = 0xff;
     s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -127,7 +128,9 @@ static int mpegps_read_header(AVFormatContext *s)
     if (!m->sofdec)
        avio_seek(s->pb, last_pos, SEEK_SET);
 
-    /* no need to do more */
+    /* discover existing streams */
+    av_read_frame(s, &pkt);
+    avio_seek(s->pb, 0, SEEK_SET);
     return 0;
 }
 
-- 
1.7.8.6



More information about the ffmpeg-devel mailing list