Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am using ffmpeg to create some h264 transport streams. the bitrate for video is 496k, for audio 64k. However when the ( 2-pass ) encoding is done, i get a stream with more then 600k. i am using the following syntax in my script:

filename=$(basename "$1")

ffmpeg -i $filename"."$extension -preset $preset -strict experimental -threads $threads -c:v $codec -b:v $video_med -bsf:v h264_mp4toannexb -pass 1 -an -f rawvideo -y /dev/null 
ffmpeg -y -i $filename"."$extension -preset $preset -strict experimental -threads $threads -c:a aac -cutoff $audiocutoff -profile:a $audioprofile -b:a $audio_med -ar $audiosamplerate  -c:v $codec -b:v $video_med -bsf:v h264_mp4toannexb -pass 2 $filename$suffix_med"."$streamsuffix

did i miss something? do i need to enforce the target bitrate? thanks a lot!

share|improve this question

migrated from Oct 8 '13 at 10:20

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

Thats about 7% overhead for the TS. Thats about right. ffmpeg's transport stream output is very inefficient. TS streams are divided into 188 byte packets. Each packet has a 4 byte header(leaving 184 bytes of payload), and there is one additional PES header per frame. After the overhead is added to each frame, if the frame does not end on a TS boundary, the final packet is padded out with 0xFF bytes. You can confirm this by looking at the ts file with a hex editor. You can also try to encode to an mp4 and look at the file size.

More info here:

share|improve this answer
thanks mate. that explains a lot! – zantafio Oct 7 '13 at 21:38

Where is $video_hi defined, and where is video_med used? Are you sure you have the right variables in the command?

share|improve this answer
hi beroe, thanks for that info. i snipped some stuff out of the code, so it got lost ... the original shellscript is correct. – zantafio Oct 7 '13 at 21:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.