How to use FFMpeg to do Simple Audio Conversion

Here's a simple FFmpeg how to that will cover just a portion of the framework's abilities. We will see how you can use the terminal to perform simple conversions of various audio file types including all popular and widely available formats. Using FFmpeg right from the terminal makes it better for performance compared to downloading and installing a GUI tool for FFmpeg, and can also offer more precise settings for the advanced users.

Convert Audio Files with FFMPeg

Beginning with audio conversion, I will be using two samples from Cut Chemist's live performances that are of mp3 and aif file types. Before initiating anything, make sure that you have Ffmpeg installed in your system. To do this, open a terminal and type:

ffmpeg –version

and something like that shown in the following screenshot should appear.

Check ffmpeg version


If FFmpeg is missing you can easily install it right from the same terminal by typing:

sudo apt-get install ffmpeg

if you're using Ubuntu, or:

yaourt ffmpeg

if you are an Arch user. Whatever your distribution of choice, you will most certainly find ffmpeg available in your package manager. The addition of an extra repository may be necessary.


Now if you type:

ffmpeg –help

on a terminal, you will get a picture of the power of the framework. You can use it to determine or change the volume, the audio channels, the sampling rate and so much more. Starting with the basics though, lets see how to convert both our files into wav types.

Open a terminal and go inside the folder that contains the input files (the files that are going to be converted). Ideally you can use the file manager to get there and then press right click on empty space and 'open a terminal here'. From then you can enter the following command:

ffmpeg -i filename.mp3 newfilename.wav

Here's my example:

Convert MP3 to WAV File format

In this case I renamed the file and converted it to a wav type of audio file.

Ok that was easy, but how can we determine what are the supported file types that we can convert from/to? That is as simple as typing

ffmpeg -formats

and

ffmpeg -codecs

and all supported forms will be displayed.

You can use one input file to get several different output files by just entering the name and the prefix like this:

ffmpeg -i filename.mp3 newfilename.wav newfilename.ogg newfilename.mp4

This will result in converting 3 output audio files (wav,ogg,mp4) from one mp3 file. Alternatively, you can set the desired codec using the -c command like this:

ffmpeg -i filename.mp4 c:a libopus newfilename.ogg

Now let's say we want to convert the other file I have here that is an aif to an mp3, but we don't want any kind of mp3. Suppose that we want to determine the bitrate for the output file. To do this you need to enter it in the following way:

ffmpeg -i filename.aif -b:a 320000 newfilename.mp3

Note that the bitrate is measured in bits/sec so if I want 320kbit/s I need to enter 320000.

Here's my example:

Convert AIF to MP3 or MP4 to OGG

This was just an introduction to FFmpeg's vast abilities and I hope it works as some kind of incentive for you to further discover the advanced framework.
These could be your first steps into conquering this powerful tool called FFmpeg, or just another way to do things in a more simple and understandable way. Whatever the case, you need to get deep into digging FFmpeg's amazing documentation (https://www.ffmpeg.org/documentation.html) and hopefully you'll find a lot of cool stuff to play with if you're interested.

Share this page:

12 Comment(s)