Encoding H.264/AVC videos for PS3 using ffmpeg

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. Just put them all on the same line when you type it.

ffmpeg
-r 23.98
-i FrameSequence.%04d.jpg
-i Sound.wav
-c:v libx264 -c:a libvo_aacenc
-b:v 35M
-b:a 224k
-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. (-c:v for codec video, and -c:a for codec audio)
-c:v libx264 -c:a libvo_aacenc

The video bit rate. I use 35Mbit/s for 1080p, 15 for 720p and 5 for SD.
-b:v 35M

The audio bit rate. 224kbit/s should be enough for 2 chan stereo sound.
-b:a 224k

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 version 1.0 and probably later. You can find ffmpeg for Windows here.

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.