[FFmpeg-devel] [PATCH]Accept startcode 001 when remuxing H264 into mpegts

Carl Eugen Hoyos cehoyos at ag.or.at
Tue Apr 9 15:21:33 CEST 2013


Hi!

Attached patch fixes remuxing of h264 into mpeg-ts for some wtv input files.

Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 0ddae65..b25b8ae 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1094,7 +1094,8 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
         const uint8_t *p = buf, *buf_end = p+size;
         uint32_t state = -1;
 
-        if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
+        if (pkt->size < 5 ||
+            (AV_RB32(pkt->data) != 0x0000001 && (AV_RB32(pkt->data) >> 8) != 0x000001)) {
             if (!st->nb_frames) {
             av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
                    "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");


More information about the ffmpeg-devel mailing list