on 17 March 2015. Postedin Tutorials
This article provide you a walk through to compileffmpeg/FLVTool2/Yamdi from source files on CentOS 6.
Most Linux distributions have outdated packages in their repositories socompiling those software is the best solution to have the latest updates, bugfixes and features.
Tutorial updated on March 2015 with the addition of manycodecs:
libx265, libx264, libvpx, Amr, Theora, libXvid, libogg, libopus, LAME, libfdk-aac, libfaac, libvorbis
Install development tools
To compile most of the required software, the GNU C and C++ compilers and otherdevelopment utilities must been installed first
yum groupinstall "Development Tools" -y
Dynamic Linked LibrariesPath
Linux uses a system of shared libraries, similar to Windows dlls, for theefficient use of space and resources, and modularity. The search path fordynamic libraries is configured globally in /etc/ld.so.conf.
Type these commands into SSH:
grep /usr/local/lib /etc/ld.so.conf || echo "/usr/local/lib" >> /etc/ld.so.conf
yasm
Yasm is an assembler released under the BSD license . Although it is notstrictly required for compiling the tools, it helps to improve the conversionspeed of ffmpeg when using HD codecs, so its installation is highlyrecommended. yasm is frequently available in the repositories of most popularLinux distribution, but it is preferred to install the latest version bycompiling its source code:
mkdir /usr/local/src cd /usr/local/src wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz tar zxf yasm-1.2.0.tar.gz cd yasm-1.2.0 ./configure && make && make install
Check
If the installation finished successfully we should be able to run the yasmcommand, for example:
yasm --version
yasm 1.2.0 (this is how the result should look)
Codecs and video conversion tools
Install LIBOGG
Ogg is a free, open standard container format maintained bythe Xiph.Org Foundation. The Ogg format is unrestricted by software patents andis designed to provide for efficient streaming and manipulation of high qualitydigital multimedia.
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz tar zxvf libogg-1.3.0.tar.gz cd /usr/local/src/libogg-1.3.0 make distclean ./configure && make clean && make && make install
Check
If the installation process finished ok the compiledlibraries will be placed at /usr/local/lib
ls /usr/local/lib/libogg* /usr/local/lib/libogg.a /usr/local/lib/libogg.so.0 /usr/local/lib/libogg.la /usr/local/lib/libogg.so.0.8.0
Install LIBVORBIS
Vorbis is a audio compression format. It is roughlycomparable to other formats used to store and play digital music, such as MP3,VQF, AAC, and other digital audio formats. It is different from these otherformats because it is completely free, open, and unpatented.
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz tar zxvf libvorbis-1.3.3.tar.gz cd /usr/local/src/libvorbis-1.3.3 make distclean ./configure && make clean && make && make install
Check
If the installation process finished ok the compiledlibraries will be placed at /usr/local/lib
ls /usr/local/lib/libvorbis* /usr/local/lib/libvorbis.a /usr/local/lib/libvorbisfile.so /usr/local/lib/libvorbisenc.a /usr/local/lib/libvorbisfile.so.3 /usr/local/lib/libvorbisenc.la /usr/local/lib/libvorbisfile.so.3.3.5 /usr/local/lib/libvorbisenc.so /usr/local/lib/libvorbis.la /usr/local/lib/libvorbisenc.so.2 /usr/local/lib/libvorbis.so /usr/local/lib/libvorbisenc.so.2.0.9 /usr/local/lib/libvorbis.so.0 /usr/local/lib/libvorbisfile.a /usr/local/lib/libvorbis.so.0.4.6 /usr/local/lib/libvorbisfile.la
Install LibXvid
Xvid is a video decoder and encoder library aimed atproviding the best compression efficiency and picture quality possible.
cd /usr/local/src wget http://downloads.xvid.org/downloads/xvidcore-1.3.3.tar.gz tar zxvf xvidcore-1.3.3.tar.gz cd xvidcore/build/generic ./configure make make install
check
ls /usr/local/lib/libxvid* /usr/local/lib/libxvidcore.a /usr/local/lib/libxvidcore.so.4@ /usr/local/lib/libxvidcore.so@ /usr/local/lib/libxvidcore.so.4.3
Install Theora
Theora is a free and open video compression format from theXiph.org Foundation. It can be used to distribute film and video online and ondisc without the licensing and royalty fees or vendor lock-in associated withother formats.
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz tar zxvf libtheora-1.1.1.tar.gz cd /usr/local/src/libtheora-1.1.1 ./configure && make clean && make && make install
Check
If the installation process finished ok the compiledlibraries will be placed at /usr/local/lib
ls /usr/local/lib/libtheora* /usr/local/lib/libtheora.a /usr/local/lib/libtheoraenc.so /usr/local/lib/libtheoradec.a /usr/local/lib/libtheoraenc.so.1 /usr/local/lib/libtheoradec.la /usr/local/lib/libtheoraenc.so.1.1.2 /usr/local/lib/libtheoradec.so /usr/local/lib/libtheora.la /usr/local/lib/libtheoradec.so.1 /usr/local/lib/libtheora.so /usr/local/lib/libtheoradec.so.1.1.4 /usr/local/lib/libtheora.so.0 /usr/local/lib/libtheoraenc.a /usr/local/lib/libtheora.so.0.3.10 /usr/local/lib/libtheoraenc.la
Install LIBX264
x264 is a free software library for encoding video streamsinto the H.264/MPEG-4 AVC format. It is released under the terms of the GNUGeneral Public License.
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 tar xvjf last_x264.tar.bz2
cd x264-snapshot-* make distclean ./configure --enable-shared && make clean && make && make install
The x264 project creates a daily snapshot with the format x264-snapshot-yyyymmdd-2245.tar.bz2. We recommend to use the last available snapshot.
Check
If the installation process finished ok the compiledlibraries will be placed at /usr/local/lib (the actual version number afterlibx264.so.* may vary)
ls /usr/local/lib/libx264* /usr/local/lib/libx264.so /usr/local/lib/libx264.so.124
Common Problems
No suitable assembler found. Install 'yasm' to get MMX/SSEoptimized code. If you really want to compile without asm, configure with--disable-asm.
If you get this error, then you shoulduse the disable asm option, or install yasm (version 0.6.1) using yourdistribution package manager (apt-get,yum.etc) or compiling it from the source.We do not recommend compiling the x264 libraries without yasm, as it noticeablyreduces the HD decoding and decoding speed.
Install Amr (for 3gp conversion)
3GP is a simplified version of the MPEG-4 Part 14 (MP4)container format, designed to decrease storage and bandwidth requirements inorder to accommodate mobile phones. It stores video streams as MPEG-4 Part 2 orH.263 or MPEG-4 Part 10 (AVC/H.264), and audio streams as AMR-NB, AMR-WB,AMR-WB+, AAC-LC or HE-AAC. A 3GP file is always big-endian, storing andtransferring the most significant bytes first. It also contains descriptions ofimage sizes and bitrate.
Opencore-amr is a free implementation of the of AMR-NB andAMR-WB codecs under Apache License V2.0
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz tar zxf opencore-amr-0.1.3.tar.gz cd /usr/local/src/opencore-amr-0.1.3 make distclean ./configure && make clean && make && make install
Check
If the installation process finished ok the compiledlibraries will be placed at /usr/local/lib
ls /usr/local/lib/libopencore* /usr/local/lib/libopencore-amrnb.a /usr/local/lib/libopencore-amrnb.la /usr/local/lib/libopencore-amrnb.so /usr/local/lib/libopencore-amrnb.so.0 /usr/local/lib/libopencore-amrnb.so.0.0.3 /usr/local/lib/libopencore-amrwb.a /usr/local/lib/libopencore-amrwb.la /usr/local/lib/libopencore-amrwb.so /usr/local/lib/libopencore-amrwb.so.0 /usr/local/lib/libopencore-amrwb.so.0.0.3
Install libfaac
FAAC is an MPEG-4 and MPEG-2 AAC encoder. Installing thelibfaac libraries enable ffmpeg to encode audio stream using the AAC codec
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz tar zxvf faac-1.28.tar.gz cd /usr/local/src/faac-1.28 ./configure && make clean && make && make install
Check
If the installation process finished ok the compiledlibraries will be placed at /usr/local/lib
ls /usr/local/lib/libfaac* /usr/local/lib/libfaac.a /usr/local/lib/libfaac.so /usr/local/lib/libfaac.so.0.0.0 /usr/local/lib/libfaac.la /usr/local/lib/libfaac.so.0
Common Problems
In recent Linux distrubutions (Centos 6, Debian 6) thecompilation may fail with the following error
In file included from mp4common.h:29, from 3gp.cpp:28:mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’
That is because the C function strcasestr declared in thelibfaac sources is already declared in a system-wide library.
To solve it: Edit the file /usr/local/src/faac-1.28/common/mp4v2/mpeg4ip.h anddelete the following line (around line 126)
char *strcasestr(const char *haystack, const char *needle);
Then run
make clean && ./configure && make && make install
Install libfdk-aac
The Fraunhofer FDK AAC codec library. This is currently the highest-quality AACencoder available with ffmpeg.
yum install unzip cd /usr/local/src wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master unzip fdk-aac.zip cd mstorsjo-fdk-aac* autoreconf -fiv ./configure make make install make distclean
check
ls /usr/local/lib/libfdk-aac* /usr/local/lib/libfdk-aac.a /usr/local/lib/libfdk-aac.la* /usr/local/lib/libfdk-aac.so@ /usr/local/lib/libfdk-aac.so.1@ /usr/local/lib/libfdk-aac.so.1.0.0*
Install LAME
LAME is an open source application used to encode audiointo the MP3 file format. The name LAME is a recursive acronym for LAME Ain'tan MP3 Encoder, reflecting LAME's early history when it was not actually anencoder, but merely a set of patches against the freely available ISOdemonstration source code.
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz tar zxvf lame-3.99.5.tar.gz cd lame-3.99.5 make distclean ./configure && make clean && make && make install
Check
If the installation process finished ok the compiledlibraries will be placed at /usr/local/lib
ls /usr/local/lib/libmp3lame* /usr/local/lib/libmp3lame.a /usr/local/lib/libmp3lame.so.0 /usr/local/lib/libmp3lame.la /usr/local/lib/libmp3lame.so.0.0.0 /usr/local/lib/libmp3lame.so
Install libopus
Opus is a totally open, royalty-free, highly versatile audio codec. Opus isunmatched for interactive speech and music transmission over the Internet, butis also intended for storage and streaming applications. It is standardized bythe Internet Engineering Task Force (IETF) as RFC 6716 which incorporatedtechnology from Skype's SILK codec and Xiph.Org's CELT codec.
cd /usr/local/src wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz tar zxvf opus-1.1.tar.gz cd opus-1.1 ./configure --enable-static --enable-shared make make install ldconfig
Check
ls /usr/local/lib/libopus* /usr/local/lib/libopus.a /usr/local/lib/libopus.la* /usr/local/lib/libopus.so@ /usr/local/lib/libopus.so.0@ /usr/local/lib/libopus.so.0.5.0*
Install libvpx
VP8 and VP9 are open video compression formats, aimed atproviding high picture quality at lower bitrate. libvpx provide decoding andencoding capabilities for the VP8 and VP9 formats.
The Installation Process
cd /usr/local/src wget https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2 tar xvjf libvpx-v1.3.0.tar.bz2 cd libvpx-v1.3.0 ./configure --disable-examples --enable-shared && make && make install && ldconfig
Check
ls /usr/local/lib/libvpx* /usr/local/lib/libvpx.a /usr/local/lib/libvpx.so.1 /usr/local/lib/libvpx.so.1.1.0 /usr/local/lib/libvpx.so /usr/local/lib/libvpx.so.1.1
Install libx265
x265 refers to one of the latest open source video codecused for encoding videos. It is available as free software. The x265 encoderuses the latest x265 codec based on the HEVC High Efficiency Video Coding orH.265 standard. The main objective of H.265/x265 is to improve video quality bydoubling the data compression ratio of the previous standard known asH.264/x264 encoding standard. Even if the actual browsers and mobile devices donot really support it yet, it's very interesting for our computers, or even tostore videos on our personal clouds/NAS...
cd /usr/local/src
hg clone http://hg.videolan.org/x265 cd /usr/local/src/x265/build/linux
./make-Makefiles.bash
make -j6
make install
ldconfig
Note that I used 'make -j6' because my CPU has 6Cores/threads, adapt that line to your number of cores.
check
ls /usr/local/lib/libx265*
/usr/local/lib/libx265.a /usr/local/lib/libx265.so@ /usr/local/lib/libx265.so.41*
Install Libass-devel (for the subtitles)
We need to install the EPEL repository and install it:
yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum update yum --enablerepo=epel install libass-devel
Install FFMPEG
FFMPEG is a computer program that can record, convert andstream digital audio and video in numerous formats.[1] FFMPEG is a command linetool that is composed of a collection of free software / open source libraries.It includes libavcodec, an audio/video codec library used by several otherprojects, and libavformat, an audio/video container mux and demux library. Thename of the project comes from the MPEG video standards group, together with"FF" for "fast forward".
The Installation Process
Type these commands into SSH:
cd /usr/local/src mkdir /usr/local/src/tmp chmod 777 /usr/local/src/tmp export TMPDIR=/usr/local/src/tmp wget https://www.ffmpeg.org/releases/ffmpeg-snapshot-git.tar.bz2 tar xjf ffmpeg-snapshot-git.tar.bz2 cd ffmpeg make distclean PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure --disable-static --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libfaac --enable-libvpx --enable-libvorbis --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libtheora --enable-libxvid --enable-libfdk_aac --enable-libopus --enable-libass make clean && make && make install make tools/qt-faststart cp tools/qt-faststart /usr/local/bin/ ldconfig
Metadata injection tools
Metadata, in the context of multimedia files, isinformation that complements and better describes the content, such as itsduration, author or resolution or codecs used. Although all types of multimediafiles can contain metadata (for example the ID tag in the case of mp3 files),it is specially important when converting video files to the flv format, asmetadata is required for some nice features as displaying the process bar andpseudostreaming. hwdMediaShare may use several tools for injecting metadata, soinstalling one of them is enough. If you are not interested in convertinguploaded videos to flv you don't need to install these tools either.
Yamdi
Yamdi (Yet another medata injector) is it a very efficienttool that can process big files with fast and with a low memory usage,
The Installation Process
Type these commands into SSH:
cd /usr/local/src wget http://downloads.sourceforge.net/project/yamdi/yamdi/1.8/yamdi-1.8.tar.gz tar xzf yamdi-1.8.tar.gz cd yamdi-1.8 gcc yamdi.c -o yamdi -O2 -Wall strip yamdi cp yamdi /usr/bin/yamdi
FLVTOOL2
FLVTOOL2 is probably the most popular open source tool forinjecting metadata in FLV files. It is written in Ruby, so it requires theinstallation of this programming language for it to work.
Installing Ruby
Installing Using YUM
Type these commands into SSH:
yum update yum install ruby rubygems
Common Problems
WHM/Cpanel
WHM setup may prevent that Ruby can be installed using apackage manager. To easily install Ruby in a WHM/cpanel server use the providedscript
/scripts/installruby
The Installation Process
Once installed Ruby and Ruby gems, flvtool2 can be easilyinstalled using:
gem install flvtool2
Alternatively, it can be installed using the followingprocedure:
Type these commands into SSH:
cd /usr/local/src wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz tar zxvf flvtool2-1.0.6.tgz cd /usr/local/src/flvtool2-1.0.6/ ruby setup.rb config && ruby setup.rb setup && ruby setup.rb install
Tags: TuturialHow toCentOS 6installffmpegx264x265flvtool2yamdiyasmlibogglibvorbislibxvidtheoralibx264libx265amrlibfaaclibfdk-aaclamelibopuslivpxqt-faststart