I have a video I need to convert to mp3 (from the command line - not GUI): video.mp4

I tried:

ffmpeg -i -b 192 video.mp4 video.mp3

with no success. I get the following error:

WARNING: library configuration mismatch
Seems stream 0 codec frame rate differs from container frame rate: 59.83 (29917/500) -> 59.75 (239/4)
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s 
Encoder (codec id 86017) not found for output stream #0.0

so I tried lame:

lame -h -b 192 video.mp4 video.mp3

I get:

Warning: unsupported audio format

Am I missing something?

  • 1
    change -b to -ab
    – duffydack
    Dec 2, 2011 at 15:47

11 Answers 11


For FFmpeg with Constant Bitrate Encoding (CBR):

ffmpeg -i video.mp4 -vn \
       -acodec libmp3lame -ac 2 -ab 160k -ar 48000 \

or if you want to use Variable Bitrate Encoding (VBR):

ffmpeg -i video.mp4 -vn \
       -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 \

The VBR example has a target bitrate of 165 Kbit/s with a bitrate range of 140...185.

  • 8
    Assuming that lame is already installed. Dec 2, 2011 at 16:55
  • ha thanks, that is exactly what i am looking for
    – aki
    Dec 2, 2011 at 18:37
  • 3
    The only extra step to this is sudo apt-get install libavcodec-extra-53 Apr 13, 2012 at 13:06
  • 3
    Or since this is Ubuntu, ubuntu-restricted-extras, which includes libavcodec-extra-53 among other things. You may have installed this already as the installation CD prompts to do so. Nov 21, 2012 at 8:23
  • 1
    My edit added in a VBR example and labelled the fixed bitrate example as CBR...
    – andrew.46
    May 26, 2014 at 10:55

soundconverter Install soundconverter

Install via the software center

is the leading audio file converter for the GNOME Desktop. It reads anything GStreamer can read (Ogg Vorbis, AAC, MP3, FLAC, WAV, AVI, MPEG, MOV, M4A, AC3, DTS, ALAC, MPC, Shorten, APE, SID, MOD, XM, S3M, etc...), and writes to WAV, FLAC, MP3, AAC, and Ogg Vorbis files, or use a GNOME Audio Profile.

SoundConverter aims to be simple to use, and very fast. Thanks to its multithreaded design, it will use as many cores as possible to speed up the conversion. It can also extract the audio from videos.

How to Convert MP4 to MP3 with VLC

  • Open VLC Media Player. Click "Media" > "Convert" to enter the "Open Media" window. Click the "Add" button on the right side of the screen to enter Windows Explorer. Locate the MP4 on your hard drive you want to convert. Click the "Convert" button at the bottom of the screen.

  • Select the name of the Target file.

  • Click the "Audio Codec" tab and select "MP3" from the "Codec" drop down box. Press the "Start" button to begin converting your MP4 to MP3 audio.

  • Click Start

  • 4
    But the OP asked for a command-line solution. Oct 8, 2013 at 2:25
  • 1
    This is great !!!
    – Eric
    Mar 13, 2020 at 0:27

I have a shell-script that uses mplayer (so it can convert anything mplayer can play) to extract the audio, and then encode it using lame. Here is the code:

#! /bin/bash
# any2mp3.sh
# Converts to mp3 anything mplayer can play
# Needs mplayer amd lame installed

[ $1 ] || { echo "Usage: $0 file1.wma file2.wma"; exit 1; }

for i in "$@"
    [ -f "$i" ] || { echo "File $i not found!"; exit 1; }

[ -f audiodump.wav ] && {
    echo "file audiodump.wav already exists"
    exit 1

for i in "$@"
    ext=`echo $i | sed 's/[^.]*\.\([a-zA-Z0-9]\+\)/\1/g'`
    j=`basename "$i" ".$ext"`
    echo -n "Extracting audiodump.wav from $i... "
    mplayer -vo null -vc null -af resample=44100 -ao pcm:waveheader:fast \
    "$i" >/dev/null 2>/dev/null || {
        echo "Problem extracting file $i"
        exit 1
    echo "done!"
    echo -n "Encoding to mp3... "
    lame -m s audiodump.wav -o "$j" >/dev/null 2>/dev/null
    echo "done!"
    echo "File written: $j"
# delete temporary dump file
rm -f audiodump.wav

First you need to apt-get install mplayer lame. After that, put the code in a file named ''any2mp3.sh'', give permission to execute, and put that in your $PATH, and you will be able to do:

$ any2mp3.sh file.mp4 another-file.wma yet-another.file.ogg

It will convert each file passed to an mp3 with the same name.

It's a little rough, but does the job.

  • i did everything and i get: -rw-r--r-- 1 aki aki 7104 2011-12-02 10:41 video.mp3 which does not play
    – aki
    Dec 2, 2011 at 15:43
  • that's weird... it seems that lame couldn't convert the wav. try removing the >/dev/null 2>/dev/null from the code to see the error message.
    – elias
    Dec 2, 2011 at 15:46
  • no luck, here's the output: pastebin.com/ALrTqCmk of both conversions
    – aki
    Dec 2, 2011 at 15:58
  • And does the audiodump.wav plays? If it doesn't, mplayer couldn't play the video.mp4 file, and then you're really out of luck. Maybe the file you are trying to convert is corrupted, can you test the process with another file?
    – elias
    Dec 2, 2011 at 16:06
  • no, the wav does not play, nor the mp4 from mplayer
    – aki
    Dec 2, 2011 at 16:09

I think the problem is with your syntax of the ffmpeg command.

ffmpeg -i source_filename -vn -ab 192k -acodec libmp3lame -ac 2 output_filename

should work.

  • i get: Expected number for ac but found: liblamemp3
    – aki
    Dec 2, 2011 at 13:56

I use this small script for converting m4a to mp3.

for i in *.m4a; do
    avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 "`basename "$i" .m4a`.mp3"
  • 2
    If it says avconv if not found install ffmpeg and replace it with ffmpeg
    – sanoJ
    Jun 29, 2019 at 7:49

First, you have to understand a few things.

MP3 is an audio format.

MP4 is a video format.

To get the audio out of the MP4 (and to save it as an MP3), use soundconverter Install soundconverter.

  • 2
    +1 well done for pointing out the difference between mp4 and mp3.
    – fossfreedom
    Dec 2, 2011 at 14:45

To convert Upd_Sanity.mp4 to Upd_Sanity.mp3

$ sudo apt-get install ffmpeg && sudo apt-get install libavcodec-extra-53

$ ffmpeg -i Upd_Sanity.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 Upd_Sanity.mp3

OR (as ffmpeg is deprecated)

$ avconv -i Upd_Sanity.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 Upd_Sanity.mp3


   -i        input file name
   -vn       disable video recording
   -acodec   force audio codec to libmp3lame
   -ac       set the number of audio channels
   -ar       set the audio sampling frequency

If you need to use it frequently,

STEP 1 : Create a bash function that performs conversion

## utilities.sh
echo -n "Enter source mp4 file : "
read sourceFile

echo -n "Enter destination mp3 file : "
read destFile

avconv -i $sourceFile -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 $destFile

STEP 2 : source that bash file

 $ source utilities.sh

STEP 3 : start conversion calling above function convertMP4toMP3

 $ convertMP4toMP3
 Enter source mp4 file : Upd_Sanity.mp4
 Enter destination mp3 file : UPd_sanity.mp3




It is possible to use Lame directly if you use FFmpeg and pipe the output to lame (via stdout and stdin). An example:

ffmpeg -i video.mp4 -vn -f wav - | \
       lame -V 3 - audio.mp3

This allows you to use lame's considerable commandline options if you wish to explore them...


you can try converting it by vlc or sound converter go to http://soundconverter.org/ sound converter or find in your software center or use vlc for conversion open vlc media convert/save chose your file chose output format chose name and destination and start steaming thats all


Try Transmageddon is available trough the Ubuntu Software Center http://www.linuxrising.org/index.html


Though it is GUI, you can use Audacity to control fixed or variable, as well as output quality, when doing MP4 to MP3 conversions.

Open Audacity, open the target MP4 file, click FILE, EXPORT, and then select output type (default is MP3) and click SAVE. It opens the MP4's audio channel(s), exports the MP3 audio to wherever (and whatever you save it as), and you are out of it (converting a 400-mb MP4 to MP3 on a 3Ghz AMD chip is around 10-minutes, with a 160kb/sec sample rate on the audio, and the audio file will be about half as large as the MP4).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .