To browse this website, you should unconditionally agree to its terms and conditions. If not, please stop and leave now.

Site Logo

Cool FFmpeg Tips and Tricks

This article was originally published in 2016 in the Open Source For You magazine. It was also a precursor to my book FFmpeg Quick Hacks. It has been followed up with another article titled More Cool FFmpeg Tricks in 2020 after I published the book.

FFmpeg books

Sometimes, fans of free software have to jump through many hoops to get at the good stuff. FFmpeg is one such example. Like the VLC media player, FFmpeg can handle almost any audio or video format you throw at it. Yet, most people have not even heard about FFmpeg. Once you have compiled and installed it, it will prove to be just as useful.

What is FFmpeg?

FFmpeg bills itself as a complete solution to record, convert and stream audio and video. The FFmpeg project provides four simple apps - ffprobe, ffmpeg, ffplay and ffserver. Many audio/video applications use it internally. If not directly, then via mencoder, ffmpeg is used by lots of media players, browser plugins, audio/video editors and other multimedia software. This article will focus on the ffmpeg binary executable, which can be used to convert audio/video files from one format to another.

FFMPEG Compilation

Because many audio/video codecs are encumbered by "software patents", GNU/Linux distributions have had to omit FFMPEG or bundle a less-capable FFmpeg version of it. Even if it were compiled with support for non-free encoders/decoders, there was a risk of a license violation. (Recently, FFmpeg released its Version 3 with a totally native AAC encoder but more work remains.) The solution was for users to do their own compilation. The FFmpeg Wiki site has compilation steps for several distributions. The compilation process does take a while to finish but it will eventually create the four binary executable files. Copy them to your /usr/bin directory. If you don't want to disturb the FFmpeg installation that came with your Linux distribution, then you can access the binaries by providing their full path from a different directory.

FFmpeg Compilation for AMV Support

While this FFmpeg installation covers most formats, I found that it would not encode to the audio codec of the undocumented AMV format. AMV is used by many cheap Chinese-made media players. These tiny devices are primarily FM and MP3 players with the video option added as a please-ignore-it extra. The video resolution is a luxurious 160x120! I bought one of these players without realizing all this. Fortunately, there was a Google Code project called amv-codec-tools that provided support for AMV using an old version of FFmpeg. If you need to work with this format, then build a custom FFmpeg binary, specially made for AMV, using the following commands. Copy the amv-ffmpeg that these steps generate to the /usr/bin directory.

git clone
cd amv-ffmpeg

FFmpeg Usage

Klaatu (of the Gnu World Order podcast) once provided a great video-editing tip. First downsample (lower bitrate with same resolution) the input video and create your video edits. When the video editing project file is finalized, replace the downsampled video file with the original bigger video file. This way, the video editing process and your test renderings are faster. The final rendering can take hours to finish but you do not waste much time waiting before that. You can use FFmpeg to downsample the video.

FFmpeg Automation

If you have Caja Actions or Nautilus Actions Configuration installed, then you can simply right-click media files to convert them. You will have to first write some BASH scripts that will automate the FFmpeg conversions. Nautilus Actions Configuration (Gnome 2/3) is available in most software repositories. My March 2016 article has steps for compiling Caja Actions (Mate).

Caja Actions Configuration with FFmpeg bash scripts