Tuesday, March 18, 2008

Compile And Install FFMPEG on Redhat RHEL4

I just had the wonderful opportunity to set up a video sharing site on Redhat Enterprise Linux 4. Yeah. Four.

The worst part was getting ffmpeg to work, so here are my notes.

Requirements
(download, extract, etc.)

Configure, Compile, and Install FFMPEG
./configure --enable-libmp3lame --enable-libvorbis \
--enable-libxvid --enable-shared --enable-libfaac \
--enable-libfaad --enable-gpl --enable-libtheora \
--enable-libx264
make
make install

Create Symlinks


ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
ln -s /usr/local/lib/libx264.so.58 /usr/lib/libx264.so.58
ln -s /usr/local/lib/libtheora.so.0 /usr/lib/libtheora.so.0
ln -s /usr/local/lib/libfaad.so.0 /usr/lib/libfaad.so.0
ln -s /usr/local/lib/libfaac.so.0 /usr/lib/libfaac.so.0

If you don't create these symlinks you will get errors like:
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file
Done.

Run ffmpeg and it should spit out that insane list of options, wihout any errors.

6 comments:

Derek Gathright said...

Great post. Only issue I ran into is when I tried to compile, it gave me an error that I was missing the libogg library. I ran

wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz

tar xvfz libogg-1.1.3.tar.gz

cd libogg-1.1.3

./configure && make && make install

and it worked fine.

Thanks!

Steve Kamerman said...

First, thanks for the great guide!

The symlink trick didn't work for me on RHEL x68_64 because neither /usr/lib nor /usr/local/lib are in the GNU Linker path. To properly fix this problem, instead of symlinking all the libs to another dir that might be in the ld.conf, you should make a new ld conf file that specifies the location of your libs.

Here's how I did it:


# echo /usr/local/lib > /etc/ld.so.conf.d/ffmpeg.conf
# ldconfig


That creates a new file called ffmpeg.conf in the GNU Linker shared object config directory with the path to your shared objects (.so files)

If your dist doesn't have a /etc/ld.so.conf.d dir, you can alternatively add the path /usr/local/lib to the file /etc/ld.so.conf.

In case you're wondering, ldconfig looks for all the SOs in your lib dir and caches them. This way your binaries that need access to them can find them.

Patrick said...

Thank you for the tips! I overlooked the libogg issue.

The /etc/ld.so.conf.d/ configuration dir is news to me. I wish I had known about that a long time ago!

Steve Kamerman said...

I wish I knew about it a long time too! I've been doing GNU/Linux administration for over 10 years and I never knew about it! According to the ldconfig man page, /usr/lib and /usr/local/lib are trusted directories and anything in them should automatically be available to the linker, but it doesn't work like that on my RHEL box :(.

Steve Kamerman said...

Sorry about the comment spamming, but here's another tip that sped my encodes big time - when compiling on Linux, use --enable-pthreads to allow ffmpeg to use POSIX threads. This way, when you encode something with FFMPEG you can specify the -threads options. I have dual quad core zeons on my encode machine so I specify -threads "8" to speed things up dramatically!

Patrick said...

Its not spam if its topical! =) Even though I may have posted this entry, I still need all the help I can get!

I didn't even think about threads at the time. I dread re-compiling, however, I hate fixing something that isn't broken.

Shameless plug: http://www.studentsknow.com/


I can spam my own blog, right? =)