[Ffmpeg-user] Successful ipod h264 encoding
Daniel Rogers
daniel at phasevelocity.org
Sun Jun 11 18:15:19 CEST 2006
Hi,
I've seen lots of postings on a lot of lists about unsuccessful h264
ipod encodings. Here is a post about a successful one.
First the successful command:
ffmpeg -y -i cb_d3_6.mpg -vcodec h264 -pass 1 -me full -refs 3 -subq
5 -b 700 -rc_max_rate 768 -rc_buffer_size 244 -s 320x240 -r
23.976023976 -ac 1 -max_b_frames 0 -level 13 -f h264 /dev/null &&
ffmpeg -y -i cb_d3_6.mpg -vcodec h264 -pass 2 -me full -refs 3 -subq
5 -b 700 -rc_max_rate 768 -rc_buffer_size 244 -s 320x240 -r
23.976023976 -ac 1 -max_b_frames 0 -level 13 -acodec aac -ar 48000 -
ab 160 -ac 2 test.mp4 -map 0.0 -map 0.2
The map commands are there because my source has multiple language
tracks.
The most important thing about an ipod encode is max average bitrate
of 768 and no b-frames. iTunes is very strict about the 768
requirement. If it goes over, it won't copy the file to the ipod.
With b-frames, the video won't play. Technically, iPod requires
level 1.3, baseline encoded H.264 video. The flags that set this
level of conformance are:
-vcodec h264 -rc_max_rate 768 -rc_buffer_size 244 -level 13 -
max_b_frames 0 -ac 1
This specifically refers to vbv_maxrate as 768kbs and vbv_max_bufsize
as about 2,000,000 bits and no b-frames and no cabac arithimetic
coding. (which corresponds to the specs for level 1.3 video). The
rate must also be less than or equal to 30 fps (this is an ipod
limitation, actually)
-refs 3 works. higher values mean better encodes. I am not sure
what the limits of the ipod are for this flag. The default (1) also
works. -subq 5 and -me full are for higher quality and can be
omitted for faster encode time. Two pass is also optional though it
can help stay below your max average bitrate.
Setting the bit rate is where it gets hard. For short video clips
(less than 10 minutes or so) x264 totally fails to respect your
max_rate and bitrate parameters (the shorter, the worse you will
overflow). If you have a short clip, and your bit rate goes over, you
can keep dropping the bitrate until your average bitrate is less than
or equal to 768kbps. Also, ffmpeg never reports the actual average
bitrate of the video stream. You need to look at the output of the
x264 messsages or use mp4creator -list encoded.mp4 in order to
actually examine the bitrate that iTunes considers important.
Audio is significantly easier. Max rate is 48kHz and max bitrate is
160. You can use the max.
--
Daniel
More information about the ffmpeg-user
mailing list