How to Extract MP3 Audio from AVI or WebM Videos Using FFmpeg

0saves

Introduction:

What You Will Need: a computer with FFmpeg installed. I’m providing you with a link with instructions on how to install FFmpeg on Linux, Windows or MacOS just in case if it’s not already installed.

Step-by-Step Guide:

  1. Open the Terminal or Command Prompt:
    – I think there is no need to explain you on how to open Terminal on macOS/Linux or Command Prompt on Windows if you visit my website. ;) I believe in your solid technical skills.
  2. Navigate to the Video File’s Directory:
    – Use `cd` command to navigate to the folder containing the video file you need.
  3. Run the FFmpeg Command:
    – We are presenting the command:

    ffmpeg -i sample.avi -q:a 0 -map a sample.mp3
    

    – The command options description goes below:
    – `-i sample.avi`: Specifies the input file.
    – `-q:a 0`: Sets the audio quality. 0 is the highest quality.
    – `-map a`: Maps only the audio tracks.
    – `sample.mp3`: The name of the output MP3 file.

  4. Execute the Command:
    – Do not forget to replace `sample.avi` and `sample.mp3` with file name and extensions you need.
    – You should see in the Terminal or Command Prompt as the command runs the example output as it shown below:
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
...
Stream mapping:
  Stream #0:1 -> #0:0 (opus (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to 'sample.mp3':
  Metadata:
    COMPATIBLE_BRANDS: iso6mp41
    MAJOR_BRAND     : dash
    MINOR_VERSION   : 0
    TSSE            : Lavf58.76.100
  Stream #0:0(eng): Audio: mp3, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 01:04:10.261000000
      encoder         : Lavc58.134.100 libmp3lame
size=  117368kB time=01:04:10.25 bitrate= 249.7kbits/s speed=69.9x    
video:0kB audio:117367kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000275%