going crazy

enable mp3 and amr support in ffmpeg ( Ubuntu )

July 12th, 2006 by danny

( This has been tested with Ubuntu Dapper Drake, an updated version for Edgy Eft can be found here. )

This little howto describes how to enable mp3 and amr support in ffmpeg, so you can use ffmpeg to convert any movie to and from 3gp (mobile phones) and flv (adobe flash video) formats.

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” repositories in your /etc/apt/sources.list and execute the following commands :

apt-get update

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

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

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

cd /usr/local/src

Get the ffmpeg source package :

apt-get source ffmpeg

Get the amr patch :

wget http://blogger.rukker.org/dl/ffmpeg_enable_amr.patch.bz2

Go to the ffmpeg source directory and apply the patch :

cd ffmpeg-0.cvs20050918

bzcat ../ffmpeg_enable_amr.patch.bz2 | patch -p1

Build the complete package with “risky” options :

DEB_BUILD_OPTIONS=”risky” dpkg-buildpackage

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

cd ..

dpkg -i ffmpeg_0.cvs20050918-5ubuntu1_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 !! ) :

vi /etc/apt/preferences

And add the following lines :

Package: ffmpeg
Pin: version 0.cvs20050918-5ubuntu1
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 |

28 Responses

  1. Nick Shaver Says:

    Hi,

    Is there a particular gcc version that I need to use to get this working? I had gcc-4.0 and the compile failed on swf.c. I then install gcc-3.3 because I found some complaints that swf.c didn’t work with gcc-3.4+. I did a make clean and compiled with gcc-3.3 and it’s now failing on dsputil_mmx.c:

    i386/dsputil_mmx.c: In function `transpose4×4′:
    i386/dsputil_mmx.c:623: error: can’t convert between vector values of different size
    i386/dsputil_mmx.c:624: error: can’t convert between vector values of different size
    i386/dsputil_mmx.c:625: error: can’t convert between vector values of different size
    i386/dsputil_mmx.c:626: error: can’t convert between vector values of different size
    i386/dsputil_mmx.c:630: error: incompatible type for argument 1 of `__builtin_ia32_punpckhwd’
    i386/dsputil_mmx.c:630: error: incompatible type for argument 2 of `__builtin_ia32_punpckhwd’
    i386/dsputil_mmx.c:630: error: incompatible types in assignment
    i386/dsputil_mmx.c:631: error: incompatible type for argument 1 of `__builtin_ia32_punpckhwd’
    i386/dsputil_mmx.c:631: error: incompatible type for argument 2 of `__builtin_ia32_punpckhwd’
    i386/dsputil_mmx.c:631: error: incompatible types in assignment
    i386/dsputil_mmx.c:633: error: incompatible type for argument 1 of `__builtin_ia32_punpckhdq’
    i386/dsputil_mmx.c:633: error: incompatible type for argument 2 of `__builtin_ia32_punpckhdq’
    i386/dsputil_mmx.c:633: error: incompatible types in assignment
    i386/dsputil_mmx.c:636: error: incompatible type for argument 1 of `__builtin_ia32_punpckhdq’
    i386/dsputil_mmx.c:636: error: incompatible type for argument 2 of `__builtin_ia32_punpckhdq’
    i386/dsputil_mmx.c:636: error: incompatible types in assignment
    make[1]: *** [i386/dsputil_mmx.o] Error 1
    make[1]: Leaving directory `/usr/local/src/ffmpeg-0.cvs20050918/libavcodec’
    make: *** [build-stamp] Error 2

    Any of that look familiar?

    Thanks for your help.

    Nick Shaver

  2. TheAnimaL Says:

    I had no problems compiling ffmpeg with the standard Ubuntu Dapper Drake gcc 4.0.3 version…

    My guess is that one of your development packages must be corrupt, missing or semething like that. Try to reinstall all development packages… Delete all of the ffmpeg sources and just start over…

    Or just download my pre-compiled binary at :

    http://blogger.rukker.org/dl/ffmpeg_0.cvs20050918-5ubuntu1_i386.deb

    Install the binary and don’t forget to Pin this version of ffmpeg.

  3. joseph Says:

    Can you explain how to compile mplayer with amr and 3gp audio support? :)

  4. xavi Says:

    Hi, I got a problem appling the patch:

    egaite@egaite-desktop:/usr/local/src/ffmpeg-0.cvs20050918$ sudo bzcat ffmpeg_enable_amr.patch.bz2 | patch -p1
    patching file debian/rules
    patch: **** Can’t rename file /tmp/poGEjLYt to debian/rules : Permission denied

    I will apreciated your help, thanks.

  5. danny Says:

    xavi,

    check your permissions on the file debian/rules or…
    just do the whole thing all over again as user root, do ’sudo bash’ and repeat the steps…

    danny

  6. miss tress Says:

    heyas all.
    my 40 gig drive is going to good use now. I have installed UBUNTU and have ordered KUBUNTU.
    I dont know how to install the driver for my ati radeon 9600xt.
    Actually i dont know if i am meant to be downloading and installing XFREE86 or the XORG version of the driver. I am downloading them both but i dont know how to do anything in Linux really.
    I dont know where I am meant to set up my modem or set up a net account. (no INETWIZ.EXE)
    So yeah, can someone help me out with getting my ATI driver installed?
    and does anyone know of a good long PDF file i can read and wrap my brain around.
    I’m still a Windows user, but I want to use Linux as much as possible.
    Thanks. :)

  7. Martin Says:

    That’s really cool!
    I’ve been looking for this for long time :)
    using Ubuntu Dapper (Kernel 2.6.15-27-686 GNU/Linux)

    miss tress > It takes some time but I think you will get the Ati card working…next time or if you can change it get a Nvidia card, I think we al agree that nvidia drivers are more stable on Linux distributions. You can read a lot about configuring ATI on http://ubuntuforums.org/ .

  8. Bluejacket Says:

    Your pre-compiled package works fine, thanks a lot! I tried to pin ffmpeg, but adept updater still wants to update it. I pinned it just like the other version on instructions, should I do something differently?

  9. waleed Says:

    excellent..

    know at least I can listen/convert my recordings from my mobile to mp3/wav or anything other than amr.. :)

    thanks

  10. sun Says:

    thi is my problem when i’m trying to build my package

    DEB_BUILD_OPTIONS=”risky” dpkg-buildpackage
    dpkg-buildpackage: source package is ffmpeg
    dpkg-buildpackage: source version is 3:0.cvs20060823-3.1ubuntu1
    dpkg-buildpackage: source changed by Sebastian Dröge
    dpkg-buildpackage: host architecture i386
    dpkg-buildpackage: source version without epoch 0.cvs20060823-3.1ubuntu1
    dpkg-checkbuilddeps: Unmet build dependencies: quilt
    dpkg-buildpackage: Build dependencies/conflicts unsatisfied; aborting.
    dpkg-buildpackage: (Use -d flag to override.)

    thanks

  11. hex Says:

    I got the same problem as sun, using Edgy Eft and ffmpeg-0.cvs20060823.

  12. Enrico204 Says:

    sun & hex:

    you haven’t quilt. To fix do:

    # apt-get install quilt

  13. Bob Says:

    sudo apt-get install quilt

    You need to have quilt installed - see the line “Unmet build dependencies”?

  14. Alejandro Says:

    Hola!

    I wonder if you are planning a 64bits support?
    Thanks in advance
    Alejandro

  15. Huy Says:

    Hi, I already installed quilt

    $ sudo apt-get install quilt
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    quilt is already the newest version.

    But still got the same error message when attempting to build ffmpeg
    $ DEB_BUILD_OPTIONS=”risky” dpkg-buildpackage
    dpkg-buildpackage: source package is ffmpeg
    dpkg-buildpackage: source version is 3:0.cvs20060823-3.1ubuntu1
    dpkg-buildpackage: source changed by Sebastian Dröge
    dpkg-buildpackage: host architecture i386
    dpkg-buildpackage: source version without epoch 0.cvs20060823-3.1ubuntu1
    dpkg-checkbuilddeps: Unmet build dependencies: quilt
    dpkg-buildpackage: Build dependencies/conflicts unsatisfied; aborting.
    dpkg-buildpackage: (Use -d flag to override.)

    Do you guys have any idea why? Thanks in advance.

  16. TheAnimaL Says:

    I’ll post an updated version for ubuntu edgy eft as soon as possible…

  17. Anonymous Says:

    thx

  18. TheAnimaL Says:

    But I’m a bit busy lately… :-(
    OSS is getting too populair! Too much work, too much fun :-)

  19. igooi sellthe Says:

    Great post. I?ll think about that.

  20. gnolia signwith Says:

    thanks for a nice post such as this.

  21. Ben Boons Says:

    Another thanks! Good job. BTW, I had a bunch of dependency problems so I just downloaded your binary package.

  22. Nicholas Says:

    If anyone needs pre-compiled binary for amd64, I put mine here:
    http://chew.nitric.co.za/ffmpeg_0.cvs20050918-5ubuntu1.1_amd64.deb

  23. Nalin S Says:

    Hi Animal…

    You got a really interesting blog- and I found tyhis post about compiling ffmpeg to be very interesting and informative.

    Thanks and please keep up the great work…

    -N

  24. Nalin S Says:

    by the way; is there someplace I can get the same info on windows ?
    Preferably abt compiling FFMPEG with MS Visual C++ 2005 ?
    - just wondering… would appreciate if you can please mail me, since I’m not all that regular in checking blogs nor too savy about the techs that allow tracking blogs…

  25. S Says:

    Nice.
    Quilt is also needed to compile the package.

  26. Susan Drew Nym Says:

    I had to change `dpkg -i ffmpeg_0.cvs20050918-5ubuntu1_i386.deb` to `dpkg -i ffmpeg_0.cvs20050918-5ubuntu1.1_i386.deb` (and the following steps to match).

    Other than that, worked flawlessly!

    TY!

  27. Donald Says:

    This is what I tried and the results. I could not find a coverted file.

    donald@donald:~$ ffmpeg -i abagail.3gp -vcodec mpeg4 -a codec mp3 abagail.mov
    FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
    configuration: –prefix=/usr –libdir=${prefix}/lib –incdir=${prefix}/includ e/ffmpeg –enable-shared –enable-mp3lame –enable-gpl –enable-faad –mandir=${ prefix}/share/man –enable-vorbis –enable-pthreads –enable-faac –enable-xvid –enable-dts –enable-amr_nb –enable-amr_wb –enable-pp –enable-libogg –enabl e-a52 –enable-theora –enable-libgsm –enable-x264 –enable-a52bin
    libavutil version: 49.0.0
    libavcodec version: 51.9.0
    libavformat version: 50.4.0
    built on Jun 4 2006 15:08:12, gcc: 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘abagail.3gp’:
    Duration: 00:00:09.7, start: 0.000000, bitrate: 79 kb/s
    Stream #0.0(eng), 10.00 fps(r): Video: h263, yuv420p, 128×96
    Stream #0.1(eng): Audio: amr_nb, 8000 Hz, mono
    ffmpeg: unrecognized option ‘-a’
    donald@donald:~$

  28. Craig MacKay Says:

    It worked great. Thanks!

    I am running ubuntu dapper drake. I pretty much cut and pasted all the commands and it worked first try.

    I then tested it by converted a quicktime file to 3gp and tested the file on a phone. Both the video and audio worked.

    Thanks,

    Craig

Leave a Comment

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