Linux: Convert Video to Audio using FFmpeg

You can convert any video file to audio format (extract audio from video) with the help of FFmpeg tool.

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec – the leading audio/video codec library.

Installing FFmpeg on Ubuntu Linux

sudo apt-get install ffmpeg libavcodec-extra-53

Note that you need to install both ffmpeg and libavcodec.

If you have only done the following:

sudo apt-get install ffmpeg

Then you have missed installing libavcodec codec library and you will get the following error when you try to covert video to audio format.

Encoder (codec id 86017) not found for output stream

To solve this, you need to install the missing libavcodec, with the following command:

sudo apt-get install libavcodec-extra-53

Converting video to audio

After you have successfully installed ffmpeg and libavcodec, you can now convert video file to audio file.

Here is the command structure:

ffmpeg [global_options] {[input_file_options] -i ‘input_file’} … {[output_file_options] ‘output_file’}

So, the basic command to convert any video to audio is:

ffmpeg -i input.avi output.mp3

Setting video bitrate of output file to 64 kbit/s:

ffmpeg -i input.avi -b:v 64k -bufsize 64k output.mp3

For more options, see the documentation page.

Hope it helps.
Thanks.