How-to: FFmpeg, FFmpeg-PHP, Lame, Libogg, Libvorbis, FLVtool2, Mplayer, Mencoder, AMR

Tagged: Ubuntu Date: 8th, February 2009

This howto is written for Ubuntu 8.10 and is verified to work on 8.2.2009.

I found numerous tutorials on this subject out there but they all failed me, but combination of them all was successful. So fallowing is made from 10 different tutorials.
And for all those who will ask why not just apt-get php5-ffmpeg, answer is so we can configure ffmpeg with libs and options we need.

Prepare

apt-get update
apt-get upgrade
apt-get install libjpeg-progs libjpeg62 libjpeg62-dev libsdl1.2-dev php5-dev php5-cli php5-gd build-essential unzip

Download files

cd /usr/local/src
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz
wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2
wget http://downloads.xiph.org/releases/theora/libtheora-1.0beta3.tar.gz

Unpack packages

tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.2.0.tar.gz
tar zxvf flvtool2-1.0.6.tgz
tar jxvf essential-20071007.tar.bz2
tar jxvf ffmpeg-php-0.6.0.tbz2
bzip2 -cd amrnb-7.0.0.2.tar.bz2 | tar xvf -
bzip2 -cd amrwb-7.0.0.3.tar.bz2 | tar xvf -
tar zxvf libtheora-1.0beta3.tar.gz

Install Ruby on Rails, subversion & ncurses

apt-get install subversion ruby libcurses-ruby

Fetch latest Mplayer and FFmpeg from trunk

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer
svn update

Copy codecs

mkdir /usr/local/lib/codecs
mv /usr/local/src/essential-20071007/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/

Create TMP

mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp

Install lamemp3

cd /usr/local/src/lame-3.97
./configure
make && make install

Install libogg

cd /usr/local/src/libogg-1.1.3
./configure && make && make install

Install libvorbis

cd /usr/local/src/libvorbis-1.2.0
./configure && make && make install

Install flvtool2

cd /usr/local/src/flvtool2-1.0.6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Install mplayer & mencoder

grab a snack

cd /usr/local/src/mplayer
./configure --enable-jpeg
make && make install

Install AMR

cd /usr/local/src/amrnb-7.0.0.2
./configure
make && make install

cd /usr/local/src/amrwb-7.0.0.3
./configure
make && make install

Install libtheora

cd /usr/local/src/libtheora-1.0beta3
./configure
make && make install

Install ffmpeg

cd /usr/local/src/ffmpeg/
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libtheora
make
make install

Important: You will probably get errors such as: ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file, or some other library. To solve this problem you must create symbolic links. Universal code would go something like this:

ln -s /usr/local/lib/[YOUR LIB NAME]/usr/lib/[YOUR LIB NAME]

So, if you get error for libavdevice.so.52 [YOUR LIB NAME] would be libavdevice.so.52.
Got it? Good, moving on…
Install ffmpeg-php

cd /usr/local/src/ffmpeg-php-0.6.0/
phpize
./configure --with-ffmpeg=/usr/local/ffmpeg
make
make install
echo 'extension=ffmpeg.so' >> /etc/php5/apache2/php.ini
/etc/init.d/apache2 restart

9 Responses to “How-to: FFmpeg, FFmpeg-PHP, Lame, Libogg, Libvorbis, FLVtool2, Mplayer, Mencoder, AMR”

  1. Vladimir Cvetic » Blog Archive » toGDImage() broken: Patching ffmpeg-php 0.6.0:

    [...] As fallow-up to previous post (link). [...]

  2. mysoogal:

    you need Lamp server in ubuntu installed first to follow this completely

    sudo apt-get install lamp

    php5,mysql,perl package. when completes follow this guide.

  3. error:

    Hi, I am getting an error on ubuntu jaunty
    at

    # bzip2 -cd amrnb-7.0.0.2.tar.bz2 | tar xvf –
    # bzip2 -cd amrwb-7.0.0.3.tar.bz2 | tar xvf –

    Any ideas?

    The files cannot be opened/no directory etc.

  4. Vladimir Cvetic:

    Check permissions on those files.

  5. mysoogal:

    this is script to install all the crap, name it ffmpeg.sh and run it for debian, ubuntu :o

    echo “You’re running Ubuntu version: \c”;
    version=$( cat /etc/issue | grep 8.10 >/dev/null && echo 8.10 || (cat /etc/issue | grep 8.04 >/dev/null && echo 8.04 || echo “Unsupported version of Ubuntu”) )
    echo $version

    if [ "$version" = "8.04" ]; then
    liblame=”liblame-dev”
    elif [ "$version" = "8.10" ]; then
    liblame=”libmp3lame-dev”
    else
    exit
    fi

    sudo apt-get -y update

    echo “Purging currently installed x264 libraries and ffmpeg.”
    sudo apt-get -y purge ffmpeg x264 libx264-dev

    echo “Installing dependencies.”
    sudo apt-get -y install build-essential subversion git-core checkinstall texi2html

    echo “Installing codec dev libraries.”
    sudo apt-get -y install libfaad-dev libfaac-dev $liblame libtheora-dev libvorbis-dev libxvidcore4-dev libschroedinger-dev libspeex-dev libgsm1-dev libfaac-dev libdts-dev libgsm1-dev zlib1g-dev libdc1394-dev
    sudo apt-get -y build-dep ffmpeg

    if [ "$version" = "8.04" ]; then
    echo “Need to install YASM from source.”
    wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.2.tar.gz
    tar xzvf yasm-0.7.2.tar.gz
    cd yasm-0.7.2
    ./configure
    make
    sudo checkinstall –pkgname=yasm –default
    cd ..
    else
    echo “Installing YASM from apt respositories.”
    sudo apt-get -y install yasm
    fi

    echo “Installing x264 codec.”
    git clone git://git.videolan.org/x264.git
    cd x264
    ./configure –enable-shared
    make
    sudo checkinstall –fstrans=no –install=yes –pkgname=x264 –pkgversion “1:0.svn`date +%Y%m%d`-0.0ubuntu1″ –default
    sudo ldconfig
    cd ..

    echo “Getting ffmpeg source.”
    wget http://ffmpeg.org/releases/ffmpeg-0.5.tar.bz2
    tar xjvf ffmpeg-0.5.tar.bz2
    cd ffmpeg-0.5

    echo “Installing ffmpeg.”
    ./configure –enable-gpl –enable-postproc –enable-pthreads –enable-libfaac –enable-libfaad –enable-libmp3lame –enable-libtheora –enable-libx264 –enable-libxvid –enable-libvorbis –enable-libdc1394 –enable-libgsm
    make
    sudo checkinstall –fstrans=no –install=yes –pkgname=ffmpeg –pkgversion “3:0.svn`date +%Y%m%d`-12ubuntu3″ –default

  6. haldun:

    Hi, very helpful thanks,

    ffmpeg ./configure is working but not accepting amr (not found!)–enable-libamr-nb –enable-libamr-wb.?

  7. Stan:

    Great thanks! Works for me on Ubuntu 9.10

  8. cdbrkpnt:

    hi,
    i am new to ffmpeg i got ffmpeg installed on my ubuntu 9.04 and now when i try to convert flv to mp3 the command works great in shell but when i try to exec the same in my php it is not working …

    please let me know how to fix this …

    and i need to update ffmpeg to support vhook cause i am getting

    unrecognised -vhook

    Please let me know about this …….

    Thanks …

  9. Sayan Acharjee:

    When I was trying to install ffmpeg-php on fedora 9 I got the the following error while running make command:
    make: *** No targets specified and no makefile found. Stop.

    can anyone help me with this? :|

Leave a Reply