By proceeding to accessing this website, you unconditionally agree to its terms and conditions. If not, please stop and leave now.

Books On Sale

I started publishing books in 2020 and have written 17 books. They are available at Amazon (USA, India, UK, Australia and Canada), Barnes & Noble (USA) and BooksWagon.com (India). BookDepository.com (UK) sources from Amazon UK, which has the cheapest prices, but does not charge for international shipping.

World Of Word Ladders Vastu Shastra Explained Ólafia L. Óla's Favourite Traditional Nursery Rhymes (Illustrated) A Really Traditional Alphabet Book 2020 Fresh Clean Jokes For Kids 2020 Fresh Clean Jokes For Everyone Animalia Humorosum Book cover: Dictionary Of Indian English Learn To Ride A Motorcycle In Five Minutes FFMPEG Quick Hacks CommonMark Quick Reference Email Newsletter Strategies For Profit Book cover: Cool Electronic Projects Book cover: How To Invest In Stocks

Cool FFmpeg Tips and Tricks

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

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 it. 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 https://github.com/vsubhash/amv-ffmpeg.git
cd amv-ffmpeg
./configure
make

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


References