[MEncoder-users] Recoding RM files for iPod

Ulf Magnusson ulfalizer at gmail.com
Thu Dec 27 17:56:01 CET 2007


On Dec 27, 2007 3:37 PM, James Hastings-Trew <jimht at shaw.ca> wrote:
> Ulf Magnusson wrote:
> > Actually, I managed to get it to work without using that hack, and
> > with 640x480 encoding, using the following:
> >
> > # Dump sound
> > mplayer -channels 2 -novideo -hardframedrop -ao pcm:file=$1.sound.wav $1
> > # Convert sound
> > faac --mpeg-vers 4 --obj-type LC -o $1.sound.aac $1.sound.wav
> > # Convert video
> > ~/svnmp/bin/mencoder $1 -o $1.video.264 \
> > -channels 2                             \
> > -of rawvideo                            \
> > -nosound                                \
> > -ovc x264 -x264encopts qp=20:keyint=60:nocabac:level_idc=30 \
> > -vf scale=640:480,dsize=640:480,harddup
> >
> > # Combine into MP4 container
> > /usr/local/bin/MP4Box -add $1.video.264 -add $1.sound.aac $2 -brand
> > isom:1 -fps 15.000  # it's a RM, 15 fps is correct
> >
> > That produces a file that iTunes will copy to the iPod, and that plays
> > great, except for one thing. I recoded the file from
> > http://ocw.mit.edu/ans7870/6/6.046j/f05/lecturenotes/ocw-6.046-07sep2005-220k.rm
> > . When playing back the result on the iPod, the video freezes around
> > 14:22
> >
> My guess is that it exceeds the ipod bitrate limit at that point. You
> don't have any bitrate control in your mencoder line.
>
>
> _______________________________________________
> MEncoder-users mailing list
> MEncoder-users at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/mencoder-users
>

That seems to have been it. I changed it to

-ovc x264 -x264encopts
bitrate=200:vbv_maxrate=200:keyint=60:nocabac:level_idc=30

and now it's working fine. Thanks!

Oh, and..

FOR WHOEVER WHO MIGHT BE READING THIS LATER ON LOOKING TO CONVERT
VIDEO FILES FOR THEIR IPOD (I know I read through a lot of old threads
:) ):

You want a MP4 container with H.264 video and AAC sound (a container
is just a composite file format that contains audio and video
streams). The iPod won't play MP3 sound with movies. You can use x264
to encode the video stream (it's a separate install; the command above
makes MEncoder invoke x264), and faac for the sound stream. MEncoder
(as of writing) seems to produce a broken MP4 container that won't be
accepted by iTunes. You can use MP4Box instead, a separate program
that builds MP4 containers. The commands above extract and convert the
sound and video streams separately, and then use MP4Box to combine
(also known as "muxing") them together into an MP4 container.

Things to be aware of:

1. Setting level_idc=30 (level_idc is "the  bitstream's  level  as
defined by annex A of the H.264 standard") is essential, as this is
the highest level supported by the iPod. iTunes won't accept your
files unless you do this.

2. --obj-type LC is also essential (and perhaps --mpeg-vers 4 as
well), as this is all the iPod supports.

3. You need to set the maximum bitrate with vbv_maxrate, or the video
on the iPod will freeze if the local bitrate becomes too high at some
point in the video. Some googling suggests that 768 kbps is the limit
for the current generation of iPods.

4. Watch out if you try different settings and do not delete the MP4
output of MP4Box in between. It will append streams to the existing
container instead of creating a new one, which is probably not what
you want.

5. If you're building MP4Box on OS X (and maybe other systems), you
might have to rename the INSTALL file in order for 'make install' to
work.

6. If your video gets stretched out, you need to set dsize (as seen above).

7. Make sure to get the FPS setting right in the MP4Box command.

Feel free to add to this list or correct errors and spread it on. I
thought some guide that didn't merely list a bunch of commands was
needed.

/Ulf



More information about the MEncoder-users mailing list