[FFmpeg-user] MPEG-TS trouble

gs_gail guisheng315 at gmail.com
Wed Mar 21 15:17:10 CET 2012


there is a bug in libavcodec/h264_mp4toannexb_bsf.c
when the ctx->length_size == 3 , the filter will report the error
"Invalid argument"

diff --git a/libavcodec/h264_mp4toannexb_bsf.c
b/libavcodec/h264_mp4toannexb_bsf.c
index 5085ecb..fa16f2a 100644
--- a/libavcodec/h264_mp4toannexb_bsf.c
+++ b/libavcodec/h264_mp4toannexb_bsf.c
@@ -82,8 +82,8 @@ static int
h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
 
         /* retrieve length coded size */
         ctx->length_size = (*extradata++ & 0x3) + 1;
-        if (ctx->length_size == 3)
-            return AVERROR(EINVAL);
+    //    if (ctx->length_size == 3)
+    //        return AVERROR(EINVAL);
 
         /* retrieve sps and pps unit(s) */
         unit_nb = *extradata++ & 0x1f; /* number of sps unit(s) */
@@ -146,8 +146,10 @@ pps:
             nal_size = buf[0];
         } else if (ctx->length_size == 2) {
             nal_size = AV_RB16(buf);
-        } else
-            nal_size = AV_RB32(buf);
+        } else {
+            for(nal_size = 0, unit_type = 0;
unit_type<ctx->length_size; unit_type++)
+                nal_size =  (nal_size << 8) | buf[unit_type];
+        }
 
         buf += ctx->length_size;
         unit_type = *buf & 0x1f;


在 2012-03-21三的 12:23 +0200,Andrey Utkin写道:
> 2012/3/21 Carl Eugen Hoyos <cehoyos at ag.or.at>:
> > Andrey Utkin <andrey.krieger.utkin <at> gmail.com> writes:
> >
> >> 2012/3/21 Carl Eugen Hoyos <cehoyos <at> ag.or.at>:
> >> > No transcoding takes place with above command line.
> >>
> >> Carl, i think you're wrong here, i use this bitstream filter with -c
> >> copy successfully.
> >
> > But a bitstream filter does no transcoding afaict.
> 
> Ah, sorry, i misunderstood you.
> 
> roko,
> First of all check that you use recent ffmpeg, at last 0.10 version.
> Then try doing
> ffmpeg -i rtsp://admin:admin@192.168.99.146/11 -vcodec copy -y -r 25 algo.mp4
> ffmpeg -loglevel debug -i algo.mp4 -c copy -y -r 25 -vbsf
> h264_mp4toannexb algo.ts
> And report here does error stays. If so, please share full log of
> second command execution, and algo.mp4 file.
> 




More information about the ffmpeg-user mailing list