• Home
  • Flailing Wildly
  • Résumé
  • Design
  • Code
  • Wishlist
  • About Me

Flailing Wildly
Too much straw, not enough camel.

Installing FFMPEG and FFMPEG-PHP in Fedora 8 running on Amazon EC2

by Ryan Parman • June 28, 2008 • Code, Software, Tutorials • 4 comments

I’ve spent a bit of time working with Amazon EC2 recently. One of the things I’ve been working on is getting a stable build of FFMPEG and FFMPEG-PHP running on a Fedora 8 image in Amazon EC2. This is essentially going to be a tutorial to get things up and running. Of course, your milage may vary.

These instructions apply to a 32-bit Fedora 8 installation. The hardware I primarily use happens to be on EC2, but these instructions aren’t specific to EC2. You may need to tweak things a smidge for an x64 system.

Preparing the LAMP stack (and a few other things)

For FFMPEG-PHP to work, you need to have a web server with PHP support up and running. You’ll definitely need GD for image processing and mbstring is helpful in conjunction with PHP5′s built-in iconv support for managing multiple character sets in ID3 tags.

  1. Install PHP, necessary extensions and supporting software.
    yum -y install php-devel php-gd php-mbstring gcc gcc-c++ libtool svn git yasm gsm-devel libogg-devel libvorbis-devel libtheora-devel;
  2. Also, I like to create a directory with symlinks to important files so that I can access everything more efficiently. These will be used throughout this tutorial.
    mkdir /www-config; \
    ln -s /etc/init.d/httpd /www-config/httpd; \
    ln -s /etc/httpd/conf/httpd.conf /www-config/httpd.conf; \
    ln -s /var/log/httpd/ /www-config/logs; \
    ln -s /usr/lib/php/modules/ /www-config/php5-extensions; \
    ln -s /etc/httpd/conf.d/php.conf /www-config/php.conf; \
    ln -s /etc/httpd/conf.d/ /www-config/apache-conf; \
    ln -s /etc/php.ini /www-config/php.ini; \
    ln -s /etc/php.d/ /www-config/php-ini; \
    ln -s /var/www/html/ /www-config/public-html; \
    /www-config/httpd restart;

PHP 5.x should now be installed and you should have a directory prepared that lets you easily access important files for managing your configuration.

Installing FFMPEG

FFMPEG can be fairly complicated to get running properly, so here’s what I’ve gotten working thus far.

  1. Download FFMPEG source. Export the latest FFMPEG trunk from Subversion, then change to the source directory.
    svn export svn://svn.mplayerhq.hu/ffmpeg/trunk /ffmpeg-trunk-source; \
    cd /ffmpeg-trunk-source;
  2. Install x264. Export the latest x264 trunk from Git. Enter the directory, make, install, and go back to the parent directory.
    git clone git://git.videolan.org/x264.git; \
    cd x264; \
    ./configure --prefix=/usr --enable-shared --enable-pthread; \
    make; \
    make install; \
    cd ..;
  3. Install liba52. Download the latest version of liba52 (Currently 0.7.4). Decompress the package, enter the directory, run configure, make, install, and go back to the parent directory.
    wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz; \
    tar -zxvf a52dec-0.7.4.tar.gz; \
    cd a52dec-0.7.4; \
    ./configure --prefix=/usr --enable-double; \
    make; \
    make install; \
    cd ..;
  4. Install FAAC. Download the latest version of FAAC (Currently 1.26). Decompress the package, enter the directory, create the configure file, run configure, make, install, and go back to the parent directory.
    wget http://downloads.sourceforge.net/faac/faac-1.26.tar.gz; \
    tar -zxvf faac-1.26.tar.gz; \
    cd faac; \
    autoreconf -vif; \
    ./configure --prefix=/usr; \
    make; \
    make install; \
    cd ..;
  5. Install FAAD. Download the latest version of FAAD (Currently 2.6.1). Decompress the package, enter the directory, create the configure file, run configure, make, install, and go back to the parent directory.
    wget http://downloads.sourceforge.net/faac/faad2-2.6.1.tar.gz; \
    tar -zxvf faad2-2.6.1.tar.gz; \
    cd faad2; \
    autoreconf -vif; \
    ./configure --prefix=/usr; \
    make; \
    make install; \
    cd ..;
  6. Install LAME. Download the latest version of LAME (Currently 3.98b8). Decompress the package, enter the directory, run configure, make, install, and go back to the parent directory.
    wget http://downloads.sourceforge.net/lame/lame-3.98b8.tar.gz; \
    tar -zxvf lame-3.98b8.tar.gz; \
    cd lame-3.98b8; \
    ./configure --prefix=/usr; \
    make; \
    make install; \
    cd ..;
  7. Install libmpeg2. Download the latest version of libmpeg2 (Currently 0.4.1). Decompress the package, enter the directory, run configure, make, install, and go back to the parent directory.
    wget http://libmpeg2.sourceforge.net/files/mpeg2dec-0.4.1.tar.gz; \
    tar -zxvf mpeg2dec-0.4.1.tar.gz; \
    cd mpeg2dec-0.4.1; \
    ./configure --prefix=/usr; \
    make; \
    make install; \
    cd ..;
  8. Install Xvid. Download the latest version of Xvid (Currently 1.1.3). Decompress the package, enter the directory, run configure, make, install, and go back to the parent directory.
    wget http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz; \
    tar -zxvf xvidcore-1.1.3.tar.gz; \
    cd xvidcore-1.1.3/build/generic; \
    ./configure --prefix=/usr; \
    make; \
    make install; \
    cd ../../../;
  9. Install AMR/3GPP. Download the latest version of AMR (Currently 7.0.0.1). Decompress the package, enter the directory, run configure, make, install, and go back to the parent directory.
    wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.1.tar.bz2; \
    tar -jxvf amrnb-7.0.0.1.tar.bz2; \
    cd amrnb-7.0.0.1; \
    ./configure --prefix=/usr; \
    make; \
    make install; \
    cd ../;
  10. Compile FFMPEG. Configure, make, and install the software, including all options that enable enhanced functionality.
    ./configure --prefix=/usr --enable-static --enable-shared --enable-gpl --enable-nonfree --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-liba52 --enable-liba52bin --enable-libamr-nb --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid; \
    make; make install;

Installing FFMPEG-PHP

Once you have FFMPEG functioning properly, you can install the FFMPEG-PHP extension.

  1. Download and install FFMPEG-PHP source. Enter the directory, download the source, run phpize, configure, make, install, and go back to the parent directory.
    cd /ffmpeg-trunk-source; \
    wget http://downloads.sourceforge.net/ffmpeg-php/ffmpeg-php-0.5.3.1.tbz2; \
    tar -jxvf ffmpeg-php-0.5.3.1.tbz2; \
    cd ffmpeg-php-0.5.3.1; \
    phpize; \
    ./configure --prefix=/usr; \
    make; \
    make install; \
    cd ..;
  2. Add FFMPEG-PHP to the PHP configuration.
    echo "extension=ffmpeg.so" > /www-config/php-ini/ffmpeg.ini
  3. Restart Apache.
    /www-config/httpd restart

All done!

FFMPEG and FFMPEG-PHP should now be installed and ready to go. Make sure to check your error log if something isn’t working properly.

cat /www-config/logs/error_log
Ryan Parman

Ryan Parman is an entrepreneur, open source evangelist and passionate usability advocate currently living in Seattle. He is the founder and visionary behind SimplePie and CloudFusion, co-founder of WarpShare, member of the RSS Advisory Board, and is currently with Amazon. Ryan's aptly-named blog, Flailing Wildly, is where he writes about ideas longer than 140 characters.

« Yahoo! Messenger redesign is live!
Visiting Chicago »

Discussion

Scott Penberthy

July 3, 2008

Thanks for the awesome post. After several hours, I finally got FFMPEG to build on a standard Fedora Core 4 instance from EC2 by starting with your directions.

This instance was missing a few little things. First, you need the curses.* library for a number of the front-end debugging tools:

yum install ncurses-devel

When compiling the GSM package, I had to turn off the assembler optimizations as neither ASM nor YASM would allow access to the MMX instruction on this EC2 virtual CPU.

Finally, I had to remove –libgsm and –libtheoraenc from the final ffmpeg config. I don’t know if this had anything to do with the C code that replaces the assembly code optimizations, but I suspect it does.

Ryan Parman

July 3, 2008

Yeah, you usually have to tweak things a smidge to get them to work on other systems. I have a 64-bit AMD system running FC8 as well, and I had to take a few other minor steps to get this to work. I’m not even a Linux guy — just a very, very persistent Mac user. It took me a few hours to get the raw tutorial together, then a few more weeks of on-and-off tweaking and re-compiling from scratch to get this particular set of instructions.

Scott Penberthy

July 5, 2008

I thought you’d get a kick out of the hack I put together this week with ffmpeg on ec2. Check out http://moviconz.com (its slowly coming together). ffmpeg in the cloud rocks. :-)

Pingback

Daily Digest for 2009-01-08 | Pedro Trindade

Comments for this post are now closed.

Blog search

Archives
  • 2010 (7)
  • 2009 (7)
  • 2008 (12)
  • 2007 (8)
  • 2006 (18)
  • 2005 (57)
  • 2004 (104)
  • 2003 (103)
Categories
  • Apple (43)
  • Browsers (55)
  • Code (57)
  • Creating Websites (31)
  • Design (5)
  • Digital Media (3)
  • Family Life (10)
  • Just for Fun (25)
  • Music (5)
  • Personal (32)
  • Political (12)
  • Projects (44)
  • Software (60)
  • Syndication (28)
  • Technology (75)
  • Tutorials (5)
  • TV and Movies (16)
  • Video Games (5)
  • Website (62)
  • Work and Business (3)
  • Writing (4)
Socially-aware
  • Twitter
  • Facebook
  • Flickr
  • Last.fm
  • Glue
  • YouTube
  • Delicious
  • LinkedIn
Claim to fame
  • Amazon Web Services
  • WarpShare
  • CloudFusion
  • SimplePie
Legal mumbo-jumbo

All ideas, opinions and comments I post are my own and are in no way affiliated with anybody I work with. If you quote and/or reprint something I've written or said, please direct folks back to this site as a form of attribution. I promise I'll do the same for you. Unless otherwise noted, all content on this site is copyright © 1979–2010 Ryan Parman. Powered by Rocket Sauce.