Computer Graphics, Linux and Everything…

Everything

Encoding H.264/AVC videos for PS3 using ffmpeg

by on Oct.26, 2009, under Everything

OK, I’m tired of loading up my script just to see what’s the command line to encode AVC videos for the PS3 so I’m posting it here. This way It’ll be quicker for me to come see it here.

The PS3 doesn’t play Quicktime files. It much prefers mp4, which is an open standard (not to be confused with open source). The best and fastest way I’ve found to encode mp4 files is with ffmpeg. Yes, it’s command line but it’s easy enough to remember the basic syntax rapidly.

The syntax has several blocks, depending on what you need, all blocks may not be required.

ffmpeg
-r 23.98
-i FrameSequence.%04d.jpg
-i Sound.wav
-vcodec libx264 -acodec libfaac
-b 35M -ab 224k
-mbd rd -flags 4mv,trell,aic,qprd,mv0,loop -cmp 2 -subcmp 2 -flags2 dct8x8+skiprd -level 41 -bf 3 -qmin 10
-threads 0
OutputFile.mp4

Let’s look at this in details.
It begins with the executable (duh)
ffmpeg

Then you must set the frame rate only if you’re loading a sequence of frames. BTW, it only reads jpeg and png files, and it must begin at 0 or 1.
-r 23.98

The input files, several if your audio is separated from the video.
-i FrameSequence.%04d.jpg
-i Sound.wav

The formats, determined by the codecs. AVC for Video and AAC for audio.
-vcodec libx264 -acodec libfaac

The bit rates. I use 35Mbit/s for 1080p, 15 for 720p and 5 for SD.
-b 35M -ab 224k

This line must be entered as is. It set the encoding parameters the PS3 requires.
-mbd rd -flags 4mv,trell,aic,qprd,mv0,loop -cmp 2 -subcmp 2 -flags2 dct8x8+skiprd -level 41 -bf 3 -qmin 10

This will force ffmpeg to use all the cores on your machines, potentially speeding up the conversion considerably.
-threads 0

And the output file, with the mp4 extention.
OutputFile.mp4

This command works for ffmpeg 0.5 and probably later. You can find ffmpeg for Windows here.
Thanks to this site for providing the original syntax. I added the -qmin 10 part because libx264 was acting weird without it.

It is important to know that if you’re encoding a video you have made using computer softwares, your video might look a bit too contrasted. Blacks might be too black and whites too white. This is because pixel values on your computer range from 0 to 255, and on your TV they range from 16 to 235. Any pixel that has a value below 16 in your movie will appear as black on your TV. To correct this, you must compress the colors of all the frames in your movie to make sure the darkest thing is set above 16 and the brightest thing is below 235. Then it will show up correctly on your TV when played with the PS3. There is a setting in the PS3 to avoid this, but your TV must be compatible, and not all TVs are compatible, far from it.

EDIT: with recent linux distribution (Mandriva 2010.1 in my case) comes a new version of ffmpeg. This new version requires some changes to the command line. First, you have to add the argument -vpre slow somewhere. Also, the libfaac codec has been replaced by aac. The command would then looks like this:

ffmpeg
-r 23.98
-i FrameSequence.%04d.jpg
-i Sound.wav
-vcodec libx264 -acodec aac -b 35M -ab 224k
-vpre slow -mbd rd -flags 4mv,trell,aic,qprd,mv0,loop -cmp 2 -subcmp 2 -flags2 dct8x8+skiprd -level 41 -bf 3 -qmin 10
-threads 0
OutputFile.mp4
1 Comment :, , more...

Perfect bag for EeePC 901

by on Jan.03, 2009, under Everything

Canadians, your search is over. MEC has the perfect travel bag for your EeePC 901.
The EeePC fits perfectly with its soft sleeve and the bag can hold the power adaptor in the front pocket. It really looks like MEC had designed the bag to carry an Eee PC.

Comments Off : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Related Links

Related blogs I follow, or sites I like.