Converting Video Files to H.264 MP4 Format Using HandBrake on Linux

There are many different video formats in circulation, including AVI, 3GP, MOV, MPG, WMV and the formats used by DVDs and Blu-ray. One file type that has become a common denominator across multiple platforms is the MP4 file. If you need to convert  a video file to MP4, then HandBrake is an excellent choice. It is a multi-platform, multi-threaded video transcoder that is available not only for Linux but also for OS X and Windows.

Video file formats can be a bit confusing as there is more to a video file than just the video data. A file format like MP4 is actually made up of several components. There is the file format itself; this is known as the container. It in turn contains (holds) the video, audio and subtitles (if present). Some file formats can hold almost any type of video and audio regardless of how it is encoded. For example, the Matroska (MKV) file format is not limited to any codec and can hold virtually anything.

The MP4 file format is the standard container for video and audio files encoded using the MPEG-4 standards. It can actually hold several different types of MPEG encoded video, but in general, an MP4 file is expected to contain video compressed using the H.264 video codec and audio compressed using AAC, MP3 or possibly AC3.

HandBrake is designed to create MP4 files with H.264 video and AAC audio. Here is a step by step guide to converting a video file (in this case a 3GP file from a smartphone video recording) to MP4 using HandBrake on Linux.

The first step is to install HandBrake. The best way to get the software is by adding the author’s Personal Package Archive (PPA) to your system and installing from there. To add the PPA use:


To install the software use:


You can start HandBrake either from the launcher or from a terminal. To launch it via the command line use:

Click “Source” and use the open file dialog box to find the video file you want to convert. HandBrake will parse the video file and display a summary about it. At this point, you can just press “Start” and the video will be converted to an MP4 file and stored in your “Videos” directory.


Although HandBrake’s defaults are good, there are some options which you might want to check and/or change before proceeding with the video conversion. For example, if you intend to post the video online, it is best to tick the “Web optimized” box. This will tell HandBrake to optimize the MP4 file for progressive download, meaning that the file can be streamed rather than needing to be downloaded first and then played.

Click on the “Video” tab to access the video encoding settings. Here you can choose which video encoder to use (either x264 or FFmpeg), and they alter the quality settings of the final video. The default value of RF:20 is good, but it can be tweaked, depending on your needs. The lower the RF value, the higher the quality of the video. Correspondingly, the higher the value, the lower the quality of the video. Changing the RF value will directly alter the file size of the encoded video. The lower the value, the larger the file size.


If you are using the x264 encoder, then the RF value is logarithmic. This means that small changes have a dramatic impact on the quality and file size. The RF value for the FFmpeg encoder is more linear.

Use the “Audio” tab to alter how the sound will be encoded. Select the track you want to change and then alter the encoder and bitrate accordingly. “Passthru” means the audio will not be re-encoded but rather it will be sent directly into the new video file. Click on “Advanced” to access the controls for boosting the volume (the gain) of the resulting audio stream.


On the right hand side of the HandBrake window is a list of presets. These are useful when you want to convert the video for a specific type of device. For example, the “Universal” preset automatically adds a second audio track, a duplicate of the input audio but encoded in AC3 format. The “iPod” preset uses a lower RF value, while the “Android Tablet” preset tweaks some of the advanced H.264 parameters.

To get the best results, it is advisable to experiment with a short video file and convert it several times with different settings. After each iteration, see how the settings changed the final file size and the quality of the video and audio.

If you have any questions about using HandBrake, please ask them in the comments sections and we will see if we can help.