How to convert audio to other formats from the terminal with FFmpeg

Convert with FFmpegMany users prefer to use applications with a user interface to perform our tasks. But in Linux (and macOS) there is something called a terminal (does it sound like you?), From which we can do everything without having to install extra software, as long as we remember the necessary commands. In this article we are going to show you how to convert audio to other formats using terminal and FFmpeg, something that is installed by default in most Linux distributions.

The good thing about using FFmpeg directly from the terminal is that, by not having to also move the GUI or user interface, performance and reliability will be higher. It will also be faster because you are not wasting resources on "frills". In addition, FFmpeg is a very powerful and compatible framework, which ensures that we can convert practically any audio file to any format. Here we explain how to do it.

FFmpeg is compatible with most popular formats

The first thing we will do is make sure that we have FFmpeg installed on our computer. We can do it in two ways, one of them is the official one and the other as a shortcut. The official way is to write, without the quotes, "ffmpeg -version" in the terminal, which will show us the version of the framework that we have installed and the available options. The shortcut is much simpler: we simply type the name of the framework, that is, "Ffmpeg" without the quotes. We will see something like the following:

ffmpeg in terminalIf we don't see something like the above, we install FFmpeg with the following command:

sudo apt install ffmpeg

Once installed and if you want to be impressed, you can type "ffmpeg -help" to see what it can do. There are many options, but this article is going to focus on a simple one. And now, we are going to convert the audio to other formats.

Convert MP3 to WAV with FFmpeg

Converting audio files to other formats with FFmpeg can be very simple. If this is all we want, the command will be like the following:

ffmpeg -i archivodeentrada.mp3 archivodesalida.wav

As you can see, the only thing to remember is add "-i" in front of the input file and the output file (replace "inputfile" and "outputfile" with a name of your choice). There's no more. If we want to know the formats and codecs that are available, we will write the commands "ffmpeg -formats" or "ffmpeg -codecs", always without the quotes.

Let's complicate it a bit

Now we are going to complicate it a bit. This framework allows us convert the same file to various formats at the same time. What could this be for? Well, maybe we have different devices with different compatibilities and one is better with MP3 and another with OGG. Whatever the reason, we can do it and for this it is enough to add the rest of the formats to the previous command, which would look more or less like this:

ffmpeg -i archivodeentrada.mp3 archivodesalida.wav archivodesalida.ogg archivodesalida.mp4

If we want to indicate a specific codec, we will do so by adding "c: a + codec" before the output file, which to convert an MP4 to OGG with the "libopus" codec would look like this:

ffmpeg -i archivodeentrada.mp4 c:a libopus archivodesalida.ogg

In the most difficult one, what we are going to do is convert an AIF audio file to MP3 indicating a specific bitrate, in this case 320. We will do it with the following command:

ffmpeg -i archivodeentrada.aif -b:a 320000 archivodesalida.mp3

You may be wondering: "320000?" Yes. We have to remember that the bitrate is in kbit / s, so we have to add the number we know (for example, 320) multiplied by 1000.

FFmpeg offers us much more

This powerful framework offers us this and much more. In fact, what is explained in this article is just the tip of a huge iceberg that you can see in full at this link. Another day we will explain how to record the screen with FFmpeg, something we can do without audio or with audio, in case you don't want to use applications like VLC or SimpleScreenRecorder.

Is there any other task / conversion that you usually do with FFmpeg?

OceanAudio
Related article:
Ocenaudio: an excellent multiplatform free audio editor

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

2 comments, leave yours

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   enox said

    Interesting!

    How should I convert the audio into a lightweight 3gp file without losing quality?

  2.   elier said

    Thanks for the teaching, just what I was looking for to convert from the terminal directly