A Practical Guide Of FFmpeg – Part 1

FFmpeg is a great multimedia framework that helps you deal with your audio and video files. What do I mean? You can easily convert from one format to another, extract audio from a video, compress a video and even extract pictures from a video. There are many cool things you can do with this tool. It is written mostly in C programming language and the good thing is that FFmpeg is open source. You can go on GitHub, search for the project, download the code and study it yourself. A little hacking never harmed anyone.

Download And Install FFmpeg

Installing FFmpeg on your Linux platform is not that hard. The important thing is to know a couple of commands and run them. But even if you have no idea about software installation from the command line do not worry. Unixmen has the right recipes to help  you install this multimedia framework on your system.

First let me teach you guys to compile and install FFmpeg from source. What does it mean to install software from source? It means to download the code of the tool you want to install on your system, compile it and finally do an install. There are certain steps you need to follow when installing software from source.

I love keeping things practical. So, open a new console on your Linux distribution and use the following command to download the source of FFmpeg framework from Github.

wget https://github.com/FFmpeg/FFmpeg/archive/master.zip

Then unzip the zip archive with the following command.

unzip master.zip

Once the archive is extracted run the following command.


Then install it on your system with the following command.

su -c 'make install'

Once the installation is finished you can do a simple test by running the following command on your console. If it does not print any error it means the installation has been completed successfully.


There are many other ways to install FFmpeg on your system based on the type of distribution you are running. But this article does not cover the installation for each distribution as it focuses more on the practical  usage  of FFmpeg rather than the installation of it on Linux distributions.

Compiling and installing from source should work for anyone so it is ok.

Get Information About A Video

When you do stuff with videos such as converting them, editing or hacking deep on them you for sure need to do a probe on the video file in order to analyze it at a lower level. To do this, the FFprobe tool is used. According to the official documentation, this tool  gathers information from multimedia streams and prints it in human- and machine-readable fashion. In case you want to know about streams and formats on a video or audio file this is the right tool for the job.  You just do the following.

ffprobe -show_format -show_streams losemyself.mp4

When running the above command the following output is printed on my console.

codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
codec_long_name=Advanced Audio Coding
TAG:creation_time=2015-03-06 09:05:03
format_long_name=QuickTime/MPEG-4/Motion JPEG 2000 format
TAG:creation_time=2015-03-06 09:05:01

Extract Audio From MP4 Video

When downloading a music video usually you want to import it on your Ipod so you can listen to it  but the thing  it is a very big file. So what do you do? You make use of the FFmpeg framework. It has some nice commands for extracting the audio from a video. I have the following music video on my Desktop.


The size of the  file listed above is 20.4 MB. It is a video containing some great music. I just want to extract the audio and leave the video alone. The following command will do that for me.

ffmpeg -i losemyself.mp4 -vn -acodec copy losemyselfaudio.mp4

I know you are wondering what does each option in the above command mean. Let me explain it to you in very human readable words. the option -i stands for input file, the option  -vn  means do not include the video in the output, -acodec means audio codec and copy stands for copying the audio.

Very simple and easy to understand even for someone who has no idea about audio and video. You can also do the following if you want to save the audio file as mp3.

ffmpeg -i losemyself.mp4 -vn -acodec copy losemyselfaudio.mp3

The above command will save the audio file as mp3. As you can see from the two commands the extension of the output file is very important when it comes to the results. Different extension, in this case, means different format for the audio. Both cases work for us. It is up to you to save the file either as mp4 or mp3.

Convert MP4 Video To AVI

Basic conversion of a video from one format to another is an easy thing to do with FFmpeg framework. The only thing you have to know is the extension of the video output you want. For example, I can convert my mp4 video to avi using the following command.

ffmpeg -i losemyself.m4 losemyself.avi

So easy! You can also convert the video back to mp4 using the following command.

ffmpeg -i losemyself.avi losemyself.mp4

The only thing you should care in this case is the extension of the file. The option -i should be used to specify the input file in the same way we did on extracting audio from mp4 video.

Extract A Specific Image From A Video

Sometimes you like an image on a video you are watching so much that you want to have it as a  single file your computer. And the thing is you don’t know how to get it. It is not an easy task to do unless you have the right command for it. The following command will extract a single image from a specific video and save it on your local machine.

ffmpeg -ss 13 -i losemyself.mp4 -t 1 -s 640x360 -f image2 losemyself.jpg

I know that  I have to explain every option for you guys except the option -i. The option -ss stands or starting second. This option helps to tell FFmpeg where to start the extract. The option -t is used for the number of frames to be extracted from the video. In  my case, it is limited to one frame. Then there is the  option -s which is used to tell the size of the output image file. I have used 640×360 for my case. And the final option is -f which forces the  format.

Remove Audio From Video

There are many reasons why you want to remove audio from a video. Sometimes you may need a silent video for demonstration purposes or a demo. In this case, FFmepg can help you to remove the audio part from your video file. The following command does the job for you.

ffmpeg -i losemyslf.mp4 -an -vcodec copy losemyselfsilent.mp4

The input file in the above case is losemyself.mp4.  The video is going to get copied without audio on the losemyselfsilent.mp4 file. Not that the above command is not going to overwrite the original file.


In this firs part of Practical FFmpeg On Linux series, we took a look at some practical and very useful FFmpeg tools that help Linux users in their daily life while working with video and audio on their machines. In the second  part, we will take a look at some other commands that are also very practical and easy to understand by anyone.

Make sure to practise the commands if you want to improve your FFmpeg skills.

  • N_mag

    Very cool thanks, however… where’s part 2?