going crazy

enable mp3 and amr support in ffmpeg ( Ubuntu Edgy Eft )

January 29th, 2007 by danny

I finally found some spare time to update this how to, the old how to ( Dapper Drake ) can be found here.

The standard ffmpeg package is pretty useless since it does not support mp3 and amr.

This how to describes how to enable mp3 and amr support in ffmpeg for Ubuntu Edgy Eft. So ffmpeg can be used to convert any movie, including 3gp ( mobile phones ) and flv ( adobe flash video ). If you run into troubles, check the comments below…

I’ll assume you already have the c compilers, patch tools and standard development packages installed.

First make sure that you have enabled the “multiverse” and “universe” repositories in your /etc/apt/sources.list and execute the following commands :

apt-get install quilt libsdl1.2-dev libogg-dev libvorbis-dev liba52-dev libdts-dev libimlib2-dev texi2html libraw1394-dev libdc1394-13-dev libtheora-dev libgsm1-dev liblame-dev libxvidcore4-dev libfaac-dev libfaad2-dev

Note: the above line is one line, no newlines.

Change your directory to your build directory, I always use /usr/local/src :

cd /usr/local/src

Get the ffmpeg source package :

apt-get source ffmpeg

Get the amr patch :

wget http://blogger.rukker.org/dl/ffmpeg-0.cvs20060823_enable_amr.patch.bz2

Go to the ffmpeg source directory and apply the patch :

cd ffmpeg-0.cvs20060823

bzcat ../ffmpeg-0.cvs20060823_enable_amr.patch.bz2 | patch -p1

Build the complete package with “risky” options ( as root ):

DEB_BUILD_OPTIONS=”risky” dpkg-buildpackage

Go back to /usr/local/src and install the ffmpeg and related packages :

cd ..
dpkg -i ffmpeg_0.cvs20060823-3.1ubuntu1_i386.deb libavcodec0d_0.cvs20060823-3.1ubuntu1_i386.deb libavformat0d_0.cvs20060823-3.1ubuntu1_i386.deb libpostproc0d_0.cvs20060823-3.1ubuntu1_i386.deb

Now we have ffmpeg with mp3 and amr support, now we have to prevent apt from upgrading our newly created package with newer packages without mp3 and amr support. This is called “pinning”. Create the following file with your favorite editor( vi !! ) as root :

vi /etc/apt/preferences

And add the following lines :

Package: ffmpeg
Pin: version 0.cvs20060823-3.1ubuntu1
Pin-Priority: 1001

Package: libavcodec0d
Pin: version 0.cvs20060823-3.1ubuntu1
Pin-Priority: 1001

Package: libavformat0d
Pin: version 0.cvs20060823-3.1ubuntu1
Pin-Priority: 1001

Package: libpostproc0d
Pin: version 0.cvs20060823-3.1ubuntu1
Pin-Priority: 1001

Now we can convert all kinds of formats, incuding flv and 3gp!

Convert an avi to flv :

ffmpeg -i movie.avi -acodec mp3 -ar 11025 movie.flv

Convert 3gp to mpeg4 avi :

ffmpeg -i movie.3gp -vcodec mpeg4 -acodec mp3 movie.avi

Please let me know if it worked for you ( or did not work :-) )…

Posted in Linux |

23 Responses

  1. Gustavo Narea Says:

    It worked like a charm! Thank you!

    Just a few remarks:

    1.- The universe repository must be enabled too (in order to download the source of ffmpeg).

    2.- You also need this package: libsdl1.2-dev

    3.- People must run the following commands as root:
    DEB_BUILD_OPTIONS=”risky” dpkg-buildpackage
    vi /etc/apt/preferences

    4.- The lines of /etc/apt/preferences should not have spaces at the beginning.

    BTW, do you know some workaround for me to prevent adept from suggesting me to upgrade these packages?

    Cheers!

  2. danny Says:

    Thanx Gustavo! Indeed I forgot some things :-) … I’ve updated this post…

    I’m sorry, but I’am a XFCE/GNOME user so I don’t have any experience with adept.

    Danny

  3. Ian Mantripp Says:

    Hello,
    This seems to be exactly what I’m looking for…. but will it work ‘as is’ on Mac OS X (Intel) ?

    Thanks !

  4. Ric Flomag Says:

    Thank you, it worked just fine for me !

  5. nate Says:

    hi I am having problems with the following line:

    bzcat ../ffmpeg-0.cvs20060823_enable_amr.patch.bz2 | patch -p1

    everything That i have tried (both root and non-root) I end up with this error:

    patching file debian/rules
    patch: **** Can’t rename file /tmp/poG5f1YP to debian/rules : Permission denied

    any ideas??

    thanks in advance

    nate

  6. Ric Flomag Says:

    Nate: I had the same problem using sudo. So I activated the root account (sudo passwd root) and logged as root, it worked.

    Hope it helps.
    Ric.

  7. Brian J Says:

    THANK YOU for providing this! Worked beautifully for me.

  8. lasse Says:

    do a sudo bash
    and then su -
    i guess that is better than enabling the password for root.

  9. Robert Says:

    Awesome instruction that worked perfectly. I had to created the preferences file in the apt dir, so I hope it is recognized. I also wanted to contribute this example:

    ffmpeg -i video.flv -acodec amr_nb -ab 32 -ac 1 -ar 8000 -vcodec h263 -s qcif -r 10 video.3gp

    As a way to CREATE a good 3gp file for use on cellphones etc.

  10. Chris Says:

    Thanks, it worked beautifully, and I am successfully using ffmpeg now to generate MOV from ogm files for use on my iPod video.
    Just have to find out how to prevent aptitude from updating these packages….
    Chris

  11. Chris Says:

    Oh, the /etc/apt/preferences patch works for aptitude!
    I just had to create the file.
    Chris

  12. Jonathan Says:

    Hi,
    I tried to do this but I am getting some problems installing the packages. It cannot find the liblame package and all packages after that in the list. I’ve checked my sources.list and it looks alright, anybody can help ?
    Cheers,
    Jonathan

  13. Mik Says:

    Thanks for the hard work! It really helped me out.

  14. Jonathan Says:

    Hi all,
    now got everything to compile and so on. Problem is when I try and encode an avi to flv I do not get any sound. It seems the mp3 codec is not recognised/compiled with my ffmpeg. Any idea why ?
    /J

  15. Jonathan Says:

    now got everything to compile and so on. Problem is when I try and encode an avi to flv I do not get any sound. It seems the mp3 codec is not recognised/compiled with my ffmpeg. Any idea why ?
    /J

  16. goatboy Says:

    I’m having problems with this line:

    DEB_BUILD_OPTIONS=”risky” dpkg-buildpackage

    Whatever I try i get this error message:

    bash: dpkg-buildpackage: command not found

  17. soger Says:

    For goatboy:

    whenever your ubuntu installation misses any file, you can try to go to packages.ubuntu.com, there is a section called “Search the contents of packages”, enter the file name there, and the website will tell you the name of the package you need to install.

  18. TheAnimaL Says:

    Soger & Goatboy :

    You need to install the dpkg-dev package, this package provides the dpkg-buildpackage command.

  19. James Scholes Says:

    For those wanting su without enabling the root account:

    sudo -s

    Happily building now.

    Oh, and I had an error thrown up about not having ‘debhelper’ installed, but a quick apt-get solved that.

  20. Rich Says:

    I followed these instructions, but when I try to ffplay a .flv file (from YouTube), I still get errors:

    [flv @ 0xb7efa110]Unsupported video codec (4)

    Anyone help?

    thanks!

  21. Adam Says:

    Segmentation fault when converting to mp3

    I installed/pinned the package the package but am unable to convert to mp3 swf. Only flac.

    I have the dev packages installed

    :~/src# apt-get install dpkg-dev libimlib2-dev texi2html liblame-dev libfaad2-dev libmp4v2-dev libfaac-dev libxvidcore4-dev debhelper libogg-dev libvorbis-dev liba52-dev libdts-dev libsdl1.2-dev libraw1394-dev libdc1394-13-dev libtheora-dev libgsm1-dev
    Reading package lists... Done
    Building dependency tree... Done
    dpkg-dev is already the newest version.
    libimlib2-dev is already the newest version.
    texi2html is already the newest version.
    liblame-dev is already the newest version.
    libfaad2-dev is already the newest version.
    libmp4v2-dev is already the newest version.
    libfaac-dev is already the newest version.
    libxvidcore4-dev is already the newest version.
    debhelper is already the newest version.
    libogg-dev is already the newest version.
    libvorbis-dev is already the newest version.
    Note, selecting liba52-0.7.4-dev instead of liba52-dev
    liba52-0.7.4-dev is already the newest version.
    libdts-dev is already the newest version.
    libsdl1.2-dev is already the newest version.
    libraw1394-dev is already the newest version.
    libdc1394-13-dev is already the newest version.
    libtheora-dev is already the newest version.
    libgsm1-dev is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.

    But get this error:

    # which ffmpeg
    /usr/bin/ffmpeg

    root@domU-....:~/src# ffmpeg -i /home/adam/1_test.wav adam.mp3
    ffmpeg version CVS, build 3276800, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: --extra-cflags=-fomit-frame-pointer -DRUNTIME_CPUDETECT --build i486-linux-gnu --enable-gpl --enable-pp --enable-zlib --enable-vorbis --enable-libogg --enable-theora --enable-a52 --enable-dts --enable-dc1394 --enable-libgsm --disable-debug --enable-mp3lame --enable-faadbin --enable-faad --enable-faac --enable-xvid --enable-amr_nb --prefix=/usr
    built on Jul 27 2006 10:04:33, gcc: 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
    Input #0, wav, from '/home/adam/1_test.wav':
    Duration: 00:01:11.4, start: 0.000000, bitrate: 1411 kb/s
    Stream #0.0: Audio: pcm_s16le, 44100 Hz, stereo, 1411 kb/s
    Output #0, mp3, to 'adam.mp3':
    Stream #0.0: Audio: mp3, 44100 Hz, stereo, 64 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Press [q] to stop encoding
    Segmentation fault

  22. Rich Says:

    Suspect I’m only talking to myself, but in case it helps anyone else:

    Ok, I was on mplayer 0.99 (plays some but not all .flvs. If you step up to the rc release in Feisty it’s supposed to work.

  23. Cullen Says:

    Having a problem with this line

    dpkg -i ffmpeg_0.cvs20060823-3.1ubuntu1_i386.deb libavcodec0d_0.cvs20060823-3.1ubuntu1_i386.deb libavformat0d_0.cvs20060823-3.1ubuntu1_i386.deb libpostproc0d_0.cvs20060823-3.1ubuntu1_i386.deb

    I get this

    dpkg: error processing ffmpeg_0.cvs20060823-3.1ubuntu1_i386.deb (–install):
    cannot access archive: No such file or directory
    dpkg: error processing libavcodec0d_0.cvs20060823-3.1ubuntu1_i386.deb (–install):
    cannot access archive: No such file or directory
    dpkg: error processing libavformat0d_0.cvs20060823-3.1ubuntu1_i386.deb (–install):
    cannot access archive: No such file or directory
    dpkg: error processing libpostproc0d_0.cvs20060823-3.1ubuntu1_i386.deb (–install):
    cannot access archive: No such file or directory
    Errors were encountered while processing:
    ffmpeg_0.cvs20060823-3.1ubuntu1_i386.deb
    libavcodec0d_0.cvs20060823-3.1ubuntu1_i386.deb
    libavformat0d_0.cvs20060823-3.1ubuntu1_i386.deb
    libpostproc0d_0.cvs20060823-3.1ubuntu1_i386.deb

    What am I doing wrong?

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.