How Can I Extract Audio From Video With FFmpeg?

Nowadays, many people want to extract audio from the video due to various reasons. There is FFmpeg which you can use to extract audio from video on Win/Mac/Linux. Although the concept to use this is not very easy, but is not very difficult too.

In this article, you will come to know about every step that you need to follow for FFmpeg extract audio for your video. FFmpeg is a great tool to add, remove, extract audio from video files. It can not only help you extract audio but can also change the format of audio you detached from video.

Take a look!

Part 1: Extract Audio by FFmpeg on Win/Mac/Linux

FFmpeg is basically a command-based free, open-source video editor tool. It means to use this, you need to input commands to extract the audio from videos.

Steps to extract audio from MP4 video using FFmpeg:

1.1 FFmpeg for Linux

  • First, download and install the FFmpeg on your system.
  • You can go for a fairly plain version of FFmpeg. In Ubuntu – Linux, follow this command in the Terminal: sudo apt-gel install ffmpeg

  • Now, to extract audio, open the terminal from the application launcher of your system.

  • After this, you need to run cd command to navigate to your video folder to choose the video.
  • Finally, run this single command to extract MP3 from selected video file: ffmpeg -i input.avi -q:a 0 -map a output.mp3

  • Here you can change the “input.avi” to the video file name, and replace “output.mp3” with the desired audio name.
  • For instance, if you want to extract the SayGoodbye.mkv file. The command should be: ffmpeg -i SayGoodbye.mkv -q:a 0 -map a SayGoodbye.mp3

1.2 FFmpeg Extract Audio for Windows

Use these steps to extract audio from video on Windows using FFmpeg:

  • First, download the FFmpeg on your Windows system.
  • Once the download gets completed, extract the files from the folder.
  • Noe, to extract the audio from video, go to Run and type cmd, press the “Enter”. Now, you will see a command line window like this in the image.

  • After this, type cd\ and press the “Enter” key.

  • Now type cd FFmpeg Tool, to check if the tool is working or not.

  • Once you have tested that FFmpeg is working fine, then type the following command: ffmpeg -i yourvideoname.mp4 -vn -ab 128 outputaudio.mp3

  • The -vn is used to extract audio, and -ab is used to save audio as an MP3 file. By changing the value of -ab you can change the bit rate of the extracted audio.
  • In end, all the extracted output files will get automatically saved on your device.

1.3 FFmpeg for Mac

Are you using MacBook and wondering how to use the FFmpeg on it? If yes, then the bellow commands can help you. With this, you can extract the audio from video on Mac using FFmpeg.

  • First, install the FFmpeg on your MacBook. After this open the terminal and use -c copy to extract audio without re-encoding: ffmpeg -i input_file -c copy audio.m4a
  • Run ffmpeg -i input_file to see the audio format. If it is MP3 and you want AAC, change the extension of the output file to mp3.
  • This can re-encode your audio as 256 kb/s AAC: ffmpeg -i input_file -ab 256k audio.m4a

This is how you can’t only extract the audio from the video but can also change the format of audio file.

Part 2. Converting Audio into Different Formats using FFmpeg

FFmpeg is a flexible and versatile command-line tool that you can use to convert audio formats. The best thing about this tool is that it supports all popular audio as well as video formats. So, it allows you to convert the extracted audio files between various formats.

To convert audio into different formats, you need to specify the input and output file in FFmpeg. Below are some codes or commands that you can use for various audio formats.

WAV – Waveform Audio File Format

  • Change format of audio from MP3 to WMA with this code: ffmpeg -i input.mp3 output.wma
  • Get a list of audio formats supported by your device with this code: ffmpeg -formats
  • Convert WAV to MP3, and set the bit rate to 120 kbps, sample rate to 22050 Hz with: ffmpeg -i input.wav -ac 1 -ab 120000 -ar 22050 output.mp3
  • Convert MP3 file to WAV 16khz mono 16bit with this code: ffmpeg -i 111.mp3 -acodec pcm_s16le -ac 1 -ar 16000 out.wav

OGG – Free, open standard container

  • Convert ogg to ac3 with ffmpeg: ffmpeg -i audio.ogg -acodec ac3 audio.ac3
  • Change ogg to mp3 with ffmpeg: ffmpeg -i audio.ogg -acodec libmp3lame audio.mp3
  • Convert ogg to wav with ffmpeg: ffmpeg -i audio.ogg audio.wav

AAC – Advanced Audio Coding

  • Convert aac to mp3 with this code: ffmpeg -i audio.aac -acodec libmp3lame audio.mp3
  • Convert aac to wav with: ffmpeg -i audio.aac audio.wav
  • Shift aac to ac3 with this code: ffmpeg -i audio.aac -acodec ac3 audio.ac3
  • Aac to ogg format with: ffmpeg -i audio.aac -libvorbis audio.ogg

You can also use one input file to get several different formats for the output files like this: ffmpeg -i filename.mp3 newfilename.wav newfilename.ogg newfilename.mp4. This will converting 3 output audio files from one mp3 file.

So, with FFmpeg you can easily change the format of audio files.

Final Words

In this guide, you come to know about how to use ffmpeg to extract audio from video. With FFmpeg extract audio option, you can easily separate your audio from video on Windows, Linux, and MacBook. The only thing you should focus on is the codes of FFmpeg to make the conversions from video to audio.

Leave a Comment

Your email address will not be published.