Proper H.264 Encoding
Hopefully people will glom onto this information, as it’s sorely lacking. Here’s the upshot - DiVX and XViD are dead. H.264, more commonly known as MPEG-4/AVC is the new champion of compressed video. And yet, most media files are still released using DiVX and XViD, chiefly because people are not totally familiar with how to create H.264 files. What’s worse, many people simply use graphical frontends to encoding engines, which don’t provide them the newest options for H.264 encoding. The primary option for encoding movies into H.264 MP4 is QuickTime and MPEG StreamClip. These two are available for both MacOS X and Windows, and provide feature parity for MPEG-4 generation with this codec. You can get QuickTime from Apple’s website, and MPEG StreamClip from Squared5.
MPEG StreamClip’s options window for exporting to H.264.
Windows version of the same app - options are identical. Image credit: Chad Lewandowski
Another excellent option for encoding this format is MEncoder, part of the MPlayer application. Support for H.264 has recently stabilized to the point that it is able to generate H.264 / MPEG-4 content capable of being played back in other compliant players. It does have the drawback of being unable to presently encode using B-Frames, but this will hopefully be corrected soon. This tool is a command line based application, but the options are easy to comprehend and are specified in its documentation. Typically you want to enable most of them. As such, the following command line will generate high-quality output in most cases:
mencoder -of lavf -lavfopts format=mp4:i_certify_that_my_video_stream_does_not_use_b_frames -oac lavc -ovc lavc -lavcopts aglobal=1:vglobal=1:vcodec=h264:acodec=aac:vbitrate=800:abitrate=128:v4mv:coder=1:qpel:trell=lambda:mbd=1:vme=1 -vf harddup Where vbitrate and abitrate control the video and audio stream bitrates respectively. vpass= can be passed to the encoder as well. On UNIX based workstations with a properly installed MPlayer package, these options can be further explored. Hopefully this is of assistance to people looking to create media files. When looking for a video codec to use, don’t look any further than H.264. It’s the state of the art.