Extracting audio from MP4 video into MP3
Solution 1
Use ffmpeg:
ffmpeg -i input_file.mp4 -vn -b:a 128k -c:a libmp3lame output_file.mp3
(Don't forget to adjust the audio bitrate, -b:a
, otherwise you might get a huge file even for a low quality source.)
Many digital players actually support AAC audio as well, so you can try extracting the original AAC audio stream, without having to reduce quality even more:
ffmpeg -i input_file.mp4 -vn -c:a copy output_file.m4a
For older versions of ffmpeg, you'll need to use -ab
& -acodec
options instead of -b:a
& -c:a
.
Solution 2
Most MP4 videos use AAC audio, and most player devices can play AAC audio, normally in an M4A (differently-named MP4) container. Re-encoding to MP3, especially with a low bitrate input (most internet video), can lead to noticeable loss, even on low-end headphones. I would recommend using avconv
/ffmpeg
on the command-line
avconv -i input.mp4 -vn -c:a copy output.m4a
or
ffmpeg -i input.mp4 -vn -c:a copy output.m4a
To convert every MP4 in a directory:
for f in *.mp4; do avconv -i "$f" -vn -c:a copy "${f/mp4/m4a}"; done
Some players (like my cheapy cheapo mobile phone) can play AAC audio, but not in an M4A container, and for that you have to use
avconv -i input.mp4 -vn -c:a copy output.aac
Now, some older devices genuinely can't play anything but MP3, and for those you can either use grawity's solution, or
avconv -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3
This will create a variable bit rate (VBR) MP3 which, apart from specialised needs like streaming, should be preferred. -q:a 2
will get you an average (over a number of files) bit rate of around 190 kbit/s; for more information on encoding VBR MP3s, see here.
Solution 3
Use Yamb to extract the raw audio (mp4a is AAC) then use a suitable MP3 encoder.
Solution 4
grawity's answer is great! Just to add to it, if you would like to extract the audio from an MP4 and put it in an MP3 and keep the metadata (MP3 ID3 tags) then you can do this:
ffmpeg -i input_file.mp4 -map_metadata 0 -id3v2_version 3 -vn -b:a 128k -c:a libmp3lame output_file.mp3
Solution 5
If you are on a Mac, a simpler method in the future may be to right-click on the the file in the Finder, choose "Get Info", and change the extension from .mp4 to .m4a. Then open it in iTunes and convert it to an mp3.
Related videos on Youtube
OverTheRainbow
Updated on September 17, 2022Comments
-
OverTheRainbow over 1 year
I downloaded a few MP4-encoded videos from which I'd like to extract the audio stream into MP3 files for easy listening on my digital player.
Most likely, VLC can do this, but the instructions followed on their forums gave out a "bubbly" sound file.
Here are the files specifications:
- Audio mp4a 44100 Hz
- Video AVC1
-
Girardi about 11 yearsworks perfectly and is cross platform solution!
-
Elisa Cha Cha about 11 years
-abr
is not a valid option:-b:a
or-ab
can be used instead. (I know this is an old answer, but users are still referencing this.) -
judoman over 10 yearsHi. Doesn't work. Tried to open 'video.mp4' but Audacity v2.0.4 reported "video.mp4 is an Advanced Audio Coding file. Audacity cannot open this type of file. You need to convert it to a supported audio format, such as WAV or AIFF." Doh! ffmpeg worked perfect, though.
-
thepirat000 over 9 yearsI ended up using media.io
-
Marius Gedminas over 5 yearsThis worked great for me until
avconv
disappeared without notice after a bi-yearly Ubuntu upgrade.