If you are a multimedia junkie and felt it your karma to convert tons of videos and music to popular formats, then FFMPEG is the right tool for you. FFmpeg is a free video converter and so much more. It can be found in the default Ubuntu repository and also comes pre-installed in most other distro’s. It’s an open source project that contains an infinite number of libraries, the most noticeable among them is the libavcodec (for encoding and decoding of the audio and video data ) and libavformat( mux demux library).
Thats not all. It can also be used for more advanced functions like slowing down the frame rate, resizing the video and many more. Good news for geeks. FFmpeg is CLI based. So you don’t need to struggle with those unbearable mouse clicks. The latest stable release version of FFmpeg .
Converting a video using the command line.
Warning. Now if the word “command line” gives you a heart attack then you should probably skip this section and jump straight to the bottom of the page.
FFmpeg is mainly used for converting videos from one format to another. Duh!!. The most common syntax of using FFmpeg consists of the input of the file followed by the output file in the desired format.
ffmpeg -i inputvideo outputvideo.
Sounds so simple right? Well there is a glitch. The quality of the output (bit rates, frame rate) gets degraded when we use this format.
To avoid this problem we will use a number of options along with the command . Suppose we want to convert a .avi file to .flv video. Use the following command.
ffmpeg -i input.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv final.flv
After the execution processing takes place and you should see a screenshot like the one below:
No doubt, the command is very long but it is also very easy to understand. Now let’s get to know those cryptic options-
- -i = input the file
- -ab = set the audio bitrate
- -ar = setting the audio frequency
- -b = video bitrate
- -r = video frame rate
- -s = size of the video display
- -f= format
- -vcodec – is the video codec we want to use during the conversion
- -acodec- It is the audio codec we want to use during the conversion
See, we told you it would be easy.
Now lets try out some more popular options.
Convert videos from .avi to divx format.
ffmpeg -i input.avi -s 320x240 -vcodec msmpeg4v2 output.avi
Convert videos from .avi to dv format
ffmpeg -i input.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 final.dv
Convert videos from .mpg to .avi format
ffmpeg -i input.mpg ouput.avi
Convert videos from wav file to mp3 format
ffmpeg -i input.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output.mp3
Convert videos from ogg theora to mpeg format
ffmpeg -i input.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 ouput .mpg
Changing the Frame Rate
Frame rate can be defined as the number of frames displayed per sec. Frame rate is directly proportional to the speed of the video and is mainly responsible for the animation or continuous stream of images. Phew..!! Now we do not want to sound like your math teacher.
Sometimes it’s necessary for the developers to slow down the frame rate of the video , so that they can better understand about the minute changes in the video. This can be done only by including the -r option.
Syntax for the same is
ffmpeg -i inputfile -r 5 outputfile.
This will create the output video with a rate of 5 frames per second. When played, you will observe the slow processing of the video.
Extracting Audio From The Video
Sometimes you only need the audio. FFmpeg is capable of extracting the audio from the videos too .
ffmpeg -i input.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio.mp3
The -vn option holds the key to this command. This option is used when we want to disable the video recording. Executing the upper command will extract the audio file from the input.avi and willl save it under the name of “audio.mp3” .You can add more appropriate options in between if you want to juice the maximum from this niftly tool.
Converting Images To Videos
Now here is a neat little trick.
Suppose you have a collection of images named as say image1.jpg,image2.jpg and you want to view them in the video format. FFmpeg can do this job as well. You can do this by running this command on the shell.
ffmpeg -f image2 -i image%d.jpg output.mpg.
You can also do this in the reverse. So there you go. Complete video converting in Ubuntu. Play with the options and you are likely to find more cool tricks.
So thats with the geek stuff. If you want a more comprehensive list of options then type the following command in the terminal.
WinFF : GUI Client of FFmpeg
Okay. I guess you jumped straight to this one.
If you are not comfortable with the cli , don’t worry there is an equivalent GUI client for the FFmpeg called “WinFF” and it is so much more easier to use.
You can install it from the repository in ubuntu by typing
sudo apt-get install winff
To open it either use type winff in the terminal or you can go to the Applications → Sound & Video → Winff . You will see the screenshot like below
As you can see, the GUI makes the setup much more easier.
Input your video by clicking the “Add” button on the top. Then select the video and from the top down menu select the output options according to your need . Then click on the convert button on the top panel and that’s it . You are done with the formating. To set the audio video rate you need to use the”options” button. It will display the extra settings panel at the bottom of the output settings just like