FFmpeg – Easily Extract Audio From a Video File

Extract Audio From A Video File Using FFmpeg

The FFmpeg command-line tool has a ton of functionality, especially if you deal with a lot of media processing such as audio and video editing.

There are a number of reasons why you should separate audio from a video file, especially if you are involved in multimedia editing. One can add an audio segment while displaying images or any other video in the foreground rather than the original video.

Or you could also use the same audio segment in different videos and if you have a separate mp3 file from the beginning, the entire process becomes much easier. As we have already discussed, how to encode an HEVC encoded video file to h264 encoding, we will now discuss the audio extraction process in this article.

Download and Install FFmpeg

Since FFmpeg is available in the official repositories of every Linux distribution, it can be easily installed using the distribution’s package manager. Simply type the following command, depending upon your Linux distribution :

For Debian and Ubuntu-based distributions:

Open a terminal and type the following commands:

sudo apt update && sudo apt install ffmpeg

For Fedora workstation:

In the terminal, execute the following command:

sudo dnf install ffmpeg

For Arch Linux and Arch-based distributions:

Type and execute the following in the terminal :

sudo pacman -S ffmpeg

Great! You have already completed the first half of this tutorial, now we will take a look at the process through which we will separate audio from a video file.

Splitting the audio

We should first list out the streams (audio, video, and subtitles if present) using the ffprobe command which was already installed alongside FFmpeg. In the terminal, navigate to the directory where you have stored the video file and type the following command :

ffprobe <FULL_VIDEO_NAME.extension>
Find The Type Of Audio Encoding
Find The Type Of Audio Encoding using ffprobe

As we can see in the output, the file I have has AAC audio in Stream #0:1, now our output will be named Midsommar.aac. Now, to split the file, use the following command :

ffmpeg -i Midsommar.mkv -map 0:a -acodec copy Midsommar.aac
Extracting Audio From The Video File using ffmpeg
Extracting Audio From The Video File using ffmpeg

In this command,

  • -i flag signifies input (the video file)
  • and map 0:a picks up the available audio streams
  • -codec flag copies the picked up audio stream (without re-encoding it)

We can also trim out any part of the audio stream directly from the video by specifying the starting time (-ss flag) and the end time (-t flag) of the video. Type the command like this :

ffmpeg -i Midsommar.mkv -map 0:a -ss 00:03:00 -t 00:00:30.0 -acodec copy Short_Audio.aac
Trim Out Short Audio Clip From A Video
Trim Out Short Audio Clip From A Video


In this article, we have successfully learned how to extract audio from a video file, whether fully or partially, using the FFmpeg CLI (Command Line) utility. This is a highly specialized tool and the above-mentioned features are one of many.


Archwiki – ffmpeg