Multi Media

FFMpeg Extract Audio

“FFMpeg is a free and open-source video and audio converter. It has been widely adopted by many applications, including VLC, the Android OS, Spotify, etc. ffmpeg provides unparallel features for working with audio and video files.

In this tutorial, we will focus on how to extract audio files from videos and other useful techniques.”

Installing FFMpeg

Before we can proceed, you need to ensure that you have the ffmpeg utility installed and available in your system.


$ sudo apt-get install ffmpeg


$ sudo yum install epel-release
$ sudo yum localinstall --nogpgcheck
$ sudo yum install ffmpeg ffmpeg-devel


$ pacman -S ffmpeg


$ brew install ffmpeg

Keep in mind that ffmpeg may not be working depending on the system support.

You can verify that you have ffmpeg installed by running the command:

ffmpeg –version

The command should return detailed information about your installed ffmpeg version.

FFMpeg Extract Audio From Video

Before we can extract an audio file from a video, we need to determine the audio version. We can do this by running the ffbrobe command followed by the path to the target video:

$ ffprobe BigBuckBunny.mp4

Replace BigBuckBunny.mp4 with the name of your target file.

Navigate to the end of the command output and check the audio stream information. You should see the audio version as:

From the output, we can see that the audio format is aac.

To extract the audio from the video without re-encoding, run the command:

ffmpeg -i BigBuckBunny.mp4 -vn -acodec copy BigBuckBunnyAudio.aac

In the command above, we use the -I flag to specify the input video. The -vn flags tell ffmpeg to strip the video stream from the output file. Finally, the -acodec copy tells ffmpeg to use the already existing audio stream.

FFMpeg Extract Audio From File – Method 2

You can use ffmpeg to convert a video file into mp3. Since an mp3 file cannot contain a video stream, ffmpeg will automatically strip it out.

The example command is as shown:

$ ffmpeg -i BigBuckBunny.mp4 BigBuckBunnyAudio.mp3

The command will create an audio file with the specified filename.

Extract Audio From Videos in a Directory

Suppose you want to extract videos from mp4 files in an entire directory.

On Windows, run the command below in your Command Prompt.

for %i in (*.mp4) do ffmpeg -i "%i" "%~i.mp3"

The command will locate all the mp4 files in the current directory and convert them into mp3 files with similar names.

On macOS and Linux, run the command:

for i in *.mp4;
  do name=`echo "$i" | cut -d'.' -f1`
  echo "$name"
  ffmpeg -i "$i" "${name}.mp3"

Extract Audio From Video With VBR

In some cases, you may want to extract audio from video with a variable bit rate. You can run the command:

$ ffmpeg -i BigBuckBunny.mp4 -map 0:0 -q:a 0 -acodec copy BigBuckBunny.aac

We use the -q:a 0 to extract audio with variable bitrate. The quality value can range from 0 to 9, with 0 representing the highest quality and 9 representing the lowest quality.

Extract Audio From Video With CBR

To extract an audio with a constant bitrate, run the command:

$ ffmpeg -i BigBuckBunny.mp4 -map 0:0 -b:a 320k -acodec copy BigBuckBunny.aac

In the command above, we use the -b:1 followed by the target bitrate value. In our case, we specify the audio with 320k bitrate.


In this article, you learned how to extract audio from video without encoding, batch processing videos to audio, extract audio with variable bitrate and extract audio with constant bitrate.

Thanks for reading!!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list