How to Use FFmpeg to Extract Audio from Videos


To totally unlock this section you need to Log-in


Login
Command line tools use a concise interface (CLI) to interact with human rather than a graphic user interface (GUI). They usually allows you to complete task in high efficiency without frequent mouse clicks. Through this guide you will be guided on how to use the powerful and free video and audio command line tool - FFmpeg to extract audio from video file.

First of all, download FFmpeg and use Winzip, WinRAR, or 7-Zip to extract FFmpeg to a folder, for example, D:/FFmpeg. No installation needed. Then, open Windows command tool through Start -> Run and input "cmd", hit OK, then you will see a windows with black background.

How to Use FFmpeg to Extract Audio from Videos

How to Use FFmpeg to Extract Audio from Videos

To extract audio from a video using FFmpeg, simply go the folding containing FFmpeg and input command as follow. Before that, you need go to desired folder using "cd" command, e.g. "cd FFmpeg":

FFmpeg.exe -i video.mp4 -vn -ar 44100 -ac 2 -ab 192k -f mp3 audio.mp3

This FFmpeg command will extract audio track in video.mp4 file to an MP3 file with sample rate 44.1Khz (CD quality), stereo, and 2 channels. Below is a short explanation of the FFmpeg command parameters:

ffmpeg.exe: run ffmpeg the free audio extractor

-i :"input video file"
-vn:"no video"
-ac:"audio channels"
-ar:"audio rate"
-ab:"audio bit-rate"
-f :"file format"
audio.mp3: the extracted audio file name

[tweet]

This section will help you improve your FFmpeg skills. FFmpeg can do much more than extracting audio from a video.

# extract audio from video for Blackberry music

ffmpeg.exe -i video.mp4 -acodec libmp3lame -ab 160k -ac 2 -ar 44100 blackberry-music.mp3

# extract audio from video for PSP (libfaac codec required)
ffmpeg.exe -i video.mp4 -acodec libfaac -ab 128k -ar 48000 -ac 2 psp-music.mp3

# split a portion of audio file
ffmpeg.exe -i audio.mp3 -t hh:mm:ss[.xxx] -ss hh:mm:ss[.xxx] -f mp3 -y split.mp3

NOTE: -t for duration; -ss for split to start, optional if starts from beginning; xxx stands for milliseconds, which is bracketed for optional.

# combine audio and video (wav and yuv)
ffmpeg.exe -i audio.wav -s 640x480 -i video.yuv final.mpg

# identify the audio file
ffmpeg.exe -i audio.wav

# convert wav to mp3 with FFmpeg
ffmpeg.exe -i audio.wav -acodec mp3 -ab 192k audio.mp3

# convert wav to ogg with FFmpeg
ffmpeg.exe -i audio.wav -acodec vorbis -aq 60 audio.ogg

# convert wav to mp2 (resample from 44100 to 22050, stereo to mono)
ffmpeg.exe -i audio.wav -acodec mp2 -ac 1 -ar 22050 -ab 64k audio.mp2

# convert mp3 to wav for CD
ffmpeg.exe -i audio.mp3 -vn -ar 44100 audio.wav

# convert mp3 to wma
ffmpeg.exe -i audio.mp3 -acodec wmav2 -ab 160k audio.wma

#see the codecs and formats that ffmpeg can work with
ffmpeg.exe -formats