The first packet of mpeg pes files (starting with 00 00 01 e0) is
ignored by libav because the sofdec-detection in mpegps_read_header
eats the first byte. This patch adds a seek to prevent this problem
(apparently the existing code tries to solve this by modifying
m->header_state but this doesn't help since m->header_state is
overwritten at the start of mpegps_read_pes_header).
---
 libavformat/mpeg.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index f740a25..04ecea4 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -110,6 +110,7 @@ static int mpegps_read_header(AVFormatContext *s,
     MpegDemuxContext *m = s->priv_data;
     const char *sofdec = "Sofdec";
     int v, i = 0;
+    int64_t last_pos = avio_tell(s->pb);

     m->header_state = 0xff;
     s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -123,6 +124,9 @@ static int mpegps_read_header(AVFormatContext *s,

     m->sofdec = (m->sofdec == 6) ? 1 : 0;

+    if (!m->sofdec)
+        avio_seek(s->pb, last_pos, SEEK_SET);
+
     /* no need to do more */
     return 0;
 }
--
1.7.0.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to