linux poison RSS
linux poison Email

How to Extract Audio from Video file using ffmpeg

FFmpeg is a complete solution to record, convert and stream audio and video. It is a command line tool to convert one video file format to another. It also supports grabbing and encoding in real time from a TV card. Several FrontEnds/GUIs available like WinFF, Super, Avanti, AutoFF, Xpegt, GVC.

You can easily extract audio from video files such as avi, mpg, even flv into mp3 uses ffmpeg. You can even record online stream into mp3, such as stream from radio cast.

The audio component can be extracted to an mp3 using floowing command (from the command line Terminal). (This will work for any type of video file, not just Flash.)
ffmpeg -i video.flv -ab 160k -ac 2 -ar 44100 -vn audio.mp3
-i indicates the input
-ab indicates the bit rate (in this example 160kb/sec)
-vn means no video ouput
-ac 2 means 2 channels
-ar 44100 indicates the sampling frequency.

See FFMPEG docs for more info


isomorphisms said...

Is it ok to ignore most of the flags and just use -vn? I don't know what bitrate to sample at and I hope ffmpeg chooses a sensible default.

Anonymous said...

say you have multiple .flv files, how can you tell ffmpeg to make a new file name each time e.g. extracted_1.mp3 extracted_2.mp3 extracted_3.mp3 etc.?

Thanks for sharing your knowledge :)

Anonymous said...

You can just make a batch file and use wildcards.

Lauri Ranta said...

ffmpeg -i input.mkv -acodec copy output.m4a wouldn't re-encode the audio (if it was AAC). You can see the formats of the audio streams with ffmpeg -i input.mkv.

This would extract mp3 audio from multiple flv files:

for f in *.flv; do ffmpeg -i "$f" -acodec copy "${f%flv}.mp3"; done

Joe said...

Help please! I've been using ffmpeg like noted above for years with no problem. But today...

I'm getting the error message:
$ protocol not found

- both when I use mp3 and libmp3lame as the codec. This may have something to do with the new linux kernel 3.8.1 that I installed this morning, but that's a stretch, I think.

Nilesh Gupta said...

How to add songs into video which play after 10 sec but video play before 10 sec...

Anonymous said...


Post a Comment

Related Posts with Thumbnails