Compile latest ffmpeg and vlc on CentOS 6
This guide is for those who want the latest vlc player and the ffmpeg tool on CentOS 6. I used to not care much about the vlc version as long as it was able to play my content. This changed recently when I tried to play a video encoded with the V80 codec. I was running older versions of vlc (1.1.13) and ffmpeg (0.6.5), both from rpmforge and I wasn’t able to play the video properly, so I decided to upgrade. I was familiar with other repositories that provide vlc (e.g. rpmfusion) but I knew that changing repos could cause other dependency issues so I eventually chose to do a plain old source compilation.
I found this guide that proved to be very useful. What follows are the exact steps I took to compile all required libraries, ffmpeg and vlc on my 64-bit CentOS 6 machine (based on an initial minimal installation).
Install additional repositories
While this is a guide to compile from sources, some of the dependencies are already available in either the official CentOS 6 channels or compatible repositories. I had both EPEL and RPMforge installed with:
yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
I prefer disabling any non-official repositories and only enable them when I know it’s necessary. This way I can prevent dependency issues or package conflicts.
Install dependencies
- from base (the official CentOS repo):
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig wget opencv zlib-devel dbus-devel lua-devel zvbi libdvdread-devel libdc1394-devel libxcb-devel xcb-util-devel libxml2-devel mesa-libGLU-devel pulseaudio-libs-devel alsa-lib-devel libgcrypt-devel qt-devel
- from EPEL:
yum --enablerepo=epel install yasm libva-devel libass-devel libkate-devel libbluray-devel libdvdnav-devel libcddb-devel libmodplug-devel
- from RPMforge:
yum --enablerepo=rpmforge install a52dec-devel libmpeg2-devel
Create the folder structure
All source compilation will be performed in /opt/source. vlc will be install in /opt/vlc. The following command creates all required folders.
mkdir -p /opt/source/{ffmpeg,vlc} /opt/vlc
x264
cd /opt/source/ffmpeg/ git clone git://git.videolan.org/x264 cd x264 ./configure --enable-shared make make install
libfdk_aac
cd /opt/source/ffmpeg/ git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git cd fdk-aac autoreconf -fiv ./configure --enable-shared make make install
lame
cd /opt/source/ffmpeg/ wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz tar xzvf lame-3.99.5.tar.gz cd lame-3.99.5 ./configure --enable-shared --enable-nasm make make install
libogg
cd /opt/source/ffmpeg/ wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz tar xzvf libogg-1.3.0.tar.gz cd libogg-1.3.0 ./configure --enable-shared make make install
libtheora
cd /opt/source/ffmpeg/ wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz tar xzvf libtheora-1.1.1.tar.gz cd libtheora-1.1.1 ./configure --enable-shared make make install
libvorbis
cd /opt/source/ffmpeg/ wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz tar xzvf libvorbis-1.3.3.tar.gz cd libvorbis-1.3.3 ./configure --enable-shared make make install
libvpx
cd /opt/source/ffmpeg/ git clone http://git.chromium.org/webm/libvpx.git cd libvpx ./configure --enable-shared make make install
ffmpeg
cd /opt/source/ffmpeg/ git clone git://source.ffmpeg.org/ffmpeg cd ffmpeg ./configure --enable-gpl --enable-libfdk_aac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --disable-static --enable-shared make make install
libmad
cd /opt/source/ffmpeg/ wget ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz tar zxvf libmad-0.15.1b.tar.gz cd libmad-0.15.1b ./configure make make install
Note:
If the configure part doesn’t complete successfully, open the configure file with a text editor such as vim and comment or delete the following line, then re-run ./configure:
optimize="$optimize -fforce-mem"
vlc
cd /opt/source/vlc git clone git://git.videolan.org/vlc.git cd vlc ./bootstrap ./configure --prefix=/opt/vlc make make install
Note:
If you run into issues during the configure part it could be because the pkgconfig path is not defined. Export at least /usr/local/lib so vlc can detect the recently-compiled libraries, then re-run ./configure.
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH
That’s it. Launch vlc from a terminal with /opt/vlc/bin/vlc or add it to your PATH in ~/.bash_profile so you can launch with vlc:
PATH=$PATH:$HOME/bin:/opt/vlc/bin
I follow this guide on a fresh centos install and end up in error messages like:
ffmpeg: error while loading shared libraries: libx264.so.135: cannot open shared object file: No such file or directory
Sorry to hear that. Maybe there was an error in compiling x264? Did you use the exact compile options? (e.g. –enable-shared)
Yes, i have follow your tutorial except libmad and vlc cause i dont need those.
Thanks for this tutorial. I’m running a centos6 server (command line only) and all the steps install ok but when I get to ffmpeg and run make it stops with this error:
libavcodec/libavcodec.so: undefined reference to `x264_encoder_open_138′
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1
any ideas?
My guess is that the latest ffmpeg from git is too new for x264. It was 1.1 when I did the howto, but now I see there are 2 stable branches 2.0 and 1.2. You can check your version by running
and if it is 2.0, try getting the older 1.2-based tarballs from here.
I found the problem was I had remnants of an older version of x264, once I cleaned these out ffmpeg installed correctly.
A few notes:
As of today (12/06/2013) the head of the VLC GIT repo generated a bad configure file (it has sysntax error–an else statement with no action specified after it on line 54024). I had to switch to the 2.1 tag, then run ./bootstrap again to get a clean working ./configure (I used git checkout 2.1.0-git)
Also, after compiling VLC, I executed the following steps so it would find the right libraries at run time:
# cat /etc/ld.so.conf.d/vlc.conf/usr/local/lib
# ldconfig -v
I hope that helps!
I have built this successfully, with some caveats:
– liba52 was not available for me (here at CERN, it’s not straightforward to add the RPMForge repo…), so I had to compile it as explained at: http://www.linuxfromscratch.org/blfs/view/svn/multimedia/liba52.html
– I had to use the 2.1 tag of VLC, like Halfsquatch said.
Thanks a lot for this guide!
I’ve tested this procedure on RHEL7 and works fine.
Thanks!
@ Tuelho: thanks for reporting this!
Sorry,
on RHEL7 I had to do an additional step to get ffmpeg working properly. This step is described here:
http://forum.ivorde.ro/ffmpeg-error-while-loading-shared-libraries-libavdevice-so-52-cannot-open-shared-object-file-no-t129.html
Whithout this step VLC can’t play mpeg videos like mp4 and so on.
This is strange, I have never gotten this error before, but lately when I try /configure on VLC under RHEL 6.latest (6.6) I get the following error:
Requested ‘alsa >= 1.0.24′ but version of alsa is 1.0.22. alsa-lib 1.0.24 or later required.
I then passed –disable-alsa to ./configure and now I get another error I have never seen:
In file included from video_output/display.c:44:
video_output/event.h:42:2: warning: #warning FIXME: implement video close event
video_output/display.c: In function ‘VideoBufferNew’:
video_output/display.c:54: warning: unused variable ‘fmt’
video_output/display.c: In function ‘VoutDisplayCreateRender’:
video_output/display.c:442: error: unknown field ‘video’ specified in initializer
video_output/display.c:443: error: unknown field ‘buffer_new’ specified in initializer
video_output/display.c:443: warning: missing braces around initializer
video_output/display.c:443: warning: (near initialization for ‘owner..video’)
video_output/display.c: In function ‘SplitterPrepare’:
video_output/display.c:1401: warning: unused parameter ‘subpicture’
video_output/display.c: In function ‘SplitterDisplay’:
video_output/display.c:1424: warning: unused parameter ‘subpicture’
make[3]: *** [video_output/display.lo] Error 1
make[3]: Leaving directory `/opt/source/vlc/src’
make[2]: *** [all] Error 2
make[2]: Leaving directory `/opt/source/vlc/src’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/opt/source/vlc’
make: *** [all] Error 2
I have tried re-downloading the VLC GIT repo as well as the 2.1.0, 2.2.0, and master branchs/tags. Very strange. If I figure this out, I’ll post back.
Bizzare. If I can figure this out, I will post back, but
Oh, the second error is in make, not ./configure…
I was able to (mostly) follow these instructions for RHEL 7 to get VLC.latest working (I used VLC’s GIT head, so 3.0.0).
RHEL 7’s Missing RPMS:
So the following packages are not available in RHEL 7 that I can find:
libdc1394-devel
zvbi
It does not seem to matter.
No Need for rpmforge:
The rpmforge repos for RHEL 7 are incomplete do not currently include either of the packages mentioned in the rpmforge installation section.
I downloaded the source RPMs for a52dec-devel and libmpeg2-devel and compiled them on RHEL 7 with no issues. You can find the source RPMs here:
http://apt.sw.be/source/
Compat GCC:
At least one of the components compiled for FFMPEG requires the compatibility GCC compilers for C and C++ (I can’t remember which one as my bash history is not currently available):
compat-gcc-44-c++
compat-gcc-44
The Linker and Compiling ffmpeg:
I am not sure why, but it seems that ld isn’t searching paths recursivly, so I had to put an entry for each missing library reported by the following command:
ldd ffmpeg
This is mentioned by Tuelho. The link he cites was useful in troubleshooting this.
My ld.conf file for ffmpeg was as follows. I had to have each of these entries for ffmpeg to compile:
# cat /etc/ld.so.conf.d/ffmpeg.conf
/opt/source/ffmpeg/ffmpeg
/opt/source/ffmpeg/ffmpeg/libavdevice/
/opt/source/ffmpeg/ffmpeg/libavfilter/
/opt/source/ffmpeg/ffmpeg/libavformat
/opt/source/ffmpeg/ffmpeg/libavcodec
/opt/source/ffmpeg/ffmpeg/libpostproc
/opt/source/ffmpeg/ffmpeg/libswresample
/opt/source/ffmpeg/ffmpeg/libswscale
/opt/source/ffmpeg/ffmpeg/libavutil
/opt/source/ffmpeg/ffmpeg/libavformat
/opt/source/ffmpeg/ffmpeg/libavcodec
/opt/source/ffmpeg/ffmpeg/libavutil
/opt/source/ffmpeg/ffmpeg/libswscale
/opt/source/ffmpeg/ffmpeg/libpostproc
/opt/source/ffmpeg/ffmpeg/libavformat
/opt/source/ffmpeg/ffmpeg/libavcodec
/opt/source/ffmpeg/ffmpeg/libswresample
/opt/source/ffmpeg/ffmpeg/libavutil
I also kept my vlc.conf file in place, but am not sure if it’s still necessary:
cat /etc/ld.so.conf.d/vlc.conf
/usr/local/lib
@Halfsquatch: OK, so you were not able to compile on RHEL 6.6, but you were successful with RHEL 7. That’s good to know, thanks!
Wanted to thank you for posting this and leaving it up. We work in a closed lab environment, and I had need to get minimum of VLC 2.1.0 up and working, and the closest packaged VLC for RHEL 6 was 2.0.7 or .8. Needed 2.1 for java bindings, and without your site I would be pretty lost. I also had the library issue pointed out by Tuelo. Years later, and still useful. Thanks again.