19 March 2012

Converting MP4 to MP3

Problem

On Ubuntu 11.10, this error gets printed when using ffmpeg:

Encoder (codec id 86017) not found for output stream #0.0
It means that the codecs in charge of converting into mp3 are missing.

Solution

A quick and dirty solution:

sudo apt-get install libavcodec-extra-53
Note that the number at the end (53) may change over time. Compiling ffmpeg by hand from the source and installing the eventually missing codecs may be cleaner.

To check that mp3 codecs are now present:

ffmpeg -codecs | grep mp3
This returns:
  EA    libmp3lame      libmp3lame MP3 (MPEG audio layer 3)
 D A    mp3             MP3 (MPEG audio layer 3)
 D A    mp3adu          ADU (Application Data Unit) MP3 (MPEG audio layer 3)
 D A    mp3adufloat     ADU (Application Data Unit) MP3 (MPEG audio layer 3)
 D A    mp3float        MP3 (MPEG audio layer 3)
 D A    mp3on4          MP3onMP4
 D A    mp3on4float     MP3onMP4

Converting

To convert one mp4 to mp3, use:

ffmpeg -i a.mp4 -f mp3 -ab 320000 -vn a.mp3
-i to specify the input, -f the output format, -ab for the bitrate, -vn for no video.

Below, a script that converts all the mp4 in the current folder into mp3 of the same name.

#!/bin/sh
for f in *.mp4
do
    name=`echo "$f" | sed -e "s/.mp4$//g"`
    ffmpeg -i "$f" -f mp3 -ab 320000 -vn "$name.mp3"
done

Links

1 comment:

  1. Hello,I was looking for an online mp4 to mp3 converter. This post helped me a lot. Thanks for sharing !

    ReplyDelete

Note: Only a member of this blog may post a comment.