«

»

Aug 09

Install FFMPEG in Fedora/Centos/RHEL

Introduction
————
FFmpeg is a free software project that produces libraries and programs for handling multimedia data. FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation.

Reference from https://www.ffmpeg.org/about.html

How to install it?

(((First of all, please note the below installation steps are based on working with fedora/centos/rhel)))

1) Install the additional repo

Download it from http://pkgs.repoforge.org/rpmforge-release/ and choose it with your servers exact architecture and OS version.

I installed,

rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686

Since I am running Centos 6.x i686.

Update repository

# yum -y update

Install all necessary packages in support for ffmpeg

# yum install glibc gcc gcc-c++ autoconf automake libtool git make nasm pkgconfig
# yum install SDL-devel a52dec a52dec-devel alsa-lib-devel faac faac-devel faad2 faad2-devel
# yum install freetype-devel giflib gsm gsm-devel imlib2 imlib2-devel lame lame-devel libICE-devel libSM-devel libX11-devel
# yum install libXau-devel libXdmcp-devel libXext-devel libXrandr-devel libXrender-devel libXt-devel
# yum install libogg libvorbis vorbis-tools mesa-libGL-devel mesa-libGLU-devel xorg-x11-proto-devel zlib-devel
# yum install libtheora theora-tools
# yum install ncurses-devel
# yum install libdc1394 libdc1394-devel
# yum install amrnb-devel amrwb-devel opencore-amr-devel
2) Install xvid
————
It is a video codec library following the MPEG-4 standard, specifically MPEG-4 Part 2 Advanced Simple Profile (ASP). It uses ASP features such as b-frames, global and quarter pixel motion compensation, lumi masking, trellis quantization, and H.263, MPEG and custom quantization matrices.

#cd /opt
#wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
#tar xzvf xvidcore-1.3.2.tar.gz
#cd xvidcore/build/generic
#./configure –prefix=”$HOME/ffmpeg_build”
(::: Here $HOME means, since you run this as root, the home directory will be choosen as /root)
#make
#make install

3) Install LibOgg
————–
It is designed to provide for efficient streaming and manipulation of high quality digital multimedia.

#cd /opt
#wget http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz
#tar xzvf libogg-1.3.1.tar.gz
#cd libogg-1.3.1
#./configure –prefix=”$HOME/ffmpeg_build” –disable-shared
#make
#make install

4) Install Libvorbis
—————–
It is the reference implementation of the Vorbis codec. It is the lowest-level interface to the Vorbis encoder and decoder, working with packets directly.

#cd /opt
#wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
#tar xzvf libvorbis-1.3.4.tar.gz
#cd libvorbis-1.3.4
#./configure –prefix=”$HOME/ffmpeg_build” –with-ogg=”$HOME/ffmpeg_build” –disable-shared
#make
#make install

5) Install Libtheora
—————–
It is a free lossy video compression format. It is developed by the Xiph.Org Foundation and distributed without licensing fees alongside their other free and open media projects, including the Vorbis audio format and the Ogg container.

#cd /opt
#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 –prefix=”$HOME/ffmpeg_build” –with-ogg=”$HOME/ffmpeg_build” –disable-examples –disable-shared –disable-sdltest –disable-vorbistest
#make
#make install

6) Install Aacenc
————–
It’s AAC(Advanced Audio Coding) Decoder.

# cd /opt
# wget http://downloads.sourceforge.net/opencore-amr/vo-aacenc-0.1.3.tar.gz
# tar xzvf vo-aacenc-0.1.3.tar.gz
# cd vo-aacenc-0.1.3
# ./configure –prefix=”$HOME/ffmpeg_build” –disable-shared
# make
# make install

7) Install Yasm
————
It is an assembler and disassembler for the Intel x86 architecture. It can be used to write 16-bit, 32-bit (IA-32) and 64-bit (x86-64) programs. Yasm is a full rewrite of Netwide Assembler (NASM).

# yum remove yasm
# cd /opt
# wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
# tar xzfv yasm-1.2.0.tar.gz
# cd yasm-1.2.0
# ./configure –prefix=”$HOME/ffmpeg_build” –bindir=”$HOME/bin”
# make
# make install
# export “PATH=$PATH:$HOME/bin”

8) Install Libvpx
————–
It is a video compression format owned by Google.

# cd /opt
# git clone http://git.chromium.org/webm/libvpx.git
# cd libvpx
# git checkout tags/v.1.3.0
# ./configure –prefix=”$HOME/ffmpeg_build” –disable-examples
# make
# make install

9) Install X264
————
It is a free software library for encoding video streams into the H.264/MPEG-4 AVC format. It is released under the terms of the GNU General Public License.

# cd /opt
# git clone git://git.videolan.org/x264.git
# cd x264
# ./configure –prefix=”$HOME/ffmpeg_build” –bindir=”$HOME/bin” –enable-static
# make
# make install

10) Configure Libraries
——————-

# export LD_LIBRARY_PATH=/usr/local/lib/
# echo /usr/local/lib >> /etc/ld.so.conf.d/custom-libs.conf
# ldconfig (:::It configures dynamic linker run-time bindings)
11) Now compile FFMPEG
——————

# cd /opt
# git clone git://source.ffmpeg.org/ffmpeg.git
# cd ffmpeg
# git checkout release/2.2
# PKG_CONFIG_PATH=”$HOME/ffmpeg_build/lib/pkgconfig”
# export PKG_CONFIG_PATH

(((Following compile options have to given line by line)))

# ./configure –prefix=”$HOME/ffmpeg_build” –extra-cflags=”-I$HOME/ffmpeg_build/include” –extra-ldflags=”-L$HOME/ffmpeg_build/lib” –bindir=”$HOME/bin” \
–extra-libs=-ldl –enable-version3 –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libvpx –enable-libfaac \
–enable-libmp3lame –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libvo-aacenc –enable-libxvid –disable-ffplay \
–enable-gpl –enable-postproc –enable-nonfree –enable-avfilter –enable-pthreads

(((The –arch=x86_64 option should only be used if you are on a 64Bit System!)))

# make
# make install

 

An error you might come across while compiling FFMPEG
============================================

Error: libfaac not found
—————–
# cd /opt
# wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
# cd faac-1.28
# ./configure –prefix=”$HOME/ffmpeg_build” –disable-shared
# make
# make install

Then compile ffmpeg again in step 11.
Some error you encounter after compilation
=================================
# ffmpeg -version
ffmpeg: error while loading shared libraries: libvo-aacenc.so.0: cannot open shared object file: No such file or directory

For this,

# ldd `which ffmpeg`
linux-gate.so.1 => (0x00872000)
libasound.so.2 => /lib/libasound.so.2 (0x07533000)
libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0x00110000)
libpthread.so.0 => /lib/libpthread.so.0 (0x007e7000)
libvo-aacenc.so.0 => not found
libopencore-amrwb.so.0 => /usr/lib/libopencore-amrwb.so.0 (0x00f68000)
libopencore-amrnb.so.0 => /usr/lib/libopencore-amrnb.so.0 (0x00a3a000)
libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0x001b0000)
libm.so.6 => /lib/libm.so.6 (0x0082b000)
libz.so.1 => /lib/libz.so.1 (0x00816000)
librt.so.1 => /lib/librt.so.1 (0x0080b000)
libdl.so.2 => /lib/libdl.so.2 (0x00804000)
libc.so.6 => /lib/libc.so.6 (0x0065a000)
/lib/ld-linux.so.2 (0x00638000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x07afb000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x077af000)

# find / -iname libvo-aacenc.so.0
/root/ffmpeg_build/lib/libvo-aacenc.so.0

# ln -s /root/ffmpeg_build/lib/libvo-aacenc.so.0 /lib/libvo-aacenc.so.0

# ll /lib/libvo-aacenc.so.0
lrwxrwxrwx. 1 root root 40 Aug 9 17:37 /lib/libvo-aacenc.so.0 -> /root/ffmpeg_build/lib/libvo-aacenc.so.0
==========================================
Finally you are done with FFMPEG installation 🙂

# ffmpeg -version
ffmpeg version n2.2.6
built on Aug 7 2014 17:44:37 with gcc 4.4.5 (GCC) 20101112 (Red Hat 4.4.5-2)
configuration: –prefix=/root/ffmpeg_build –extra-cflags=-I/root/ffmpeg_build/include –extra-ldflags=-L/root/ffmpeg_build/lib –bindir=/root/bin –extra-libs=-ldl –enable-version3 –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libvpx –enable-libfaac –enable-libmp3lame –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libvo-aacenc –enable-libxvid –disable-ffplay –enable-gpl –enable-postproc –enable-nonfree –enable-avfilter –enable-pthreads
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100

 

See complete list of ffmpeg options using # ffmpeg -h full | less
Now I am just showing, how to convert a video type to another format. I am converting a mp4 video to avi

# ffmpeg -i my_video.mp4 my_video.avi
ffmpeg version n2.2.6 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 7 2014 17:44:37 with gcc 4.4.5 (GCC) 20101112 (Red Hat 4.4.5-2)
configuration: –prefix=/root/ffmpeg_build –extra-cflags=-I/root/ffmpeg_build/include –extra-ldflags=-L/root/ffmpeg_build/lib –bindir=/root/bin –extra-libs=-ldl –enable-version3 –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libvpx –enable-libfaac –enable-libmp3lame –enable-libtheora –enable-libvorbis –enable-libx264 –enable-libvo-aacenc –enable-libxvid –disable-ffplay –enable-gpl –enable-postproc –enable-nonfree –enable-avfilter –enable-pthreads
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘my_video.mp4’:
Metadata:
major_brand : FACE
minor_version : 1337
compatible_brands: isomavc1FACE
creation_time : 2013-01-18 03:43:54
Duration: 00:00:59.23, start: 0.000000, bitrate: 325 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 400×224, 230 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2013-01-18 03:43:54
handler_name : /tmp/tmpIZkUUJ/540138109343874.mp4_video.264 – Imported with GPAC 0.4.6-DEV-rev3544
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
Metadata:
creation_time : 2013-01-18 03:43:54
handler_name : /tmp/tmpIZkUUJ/540138109343874.mp4_audio.aac – Imported with GPAC 0.4.6-DEV-rev3544
Output #0, avi, to ‘my_video.avi’:
Metadata:
major_brand : FACE
minor_version : 1337
compatible_brands: isomavc1FACE
ISFT : Lavf55.33.100
Stream #0:0(und): Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 400×224, q=2-31, 200 kb/s, 29.97 tbn, 29.97 tbc (default)
Metadata:
creation_time : 2013-01-18 03:43:54
handler_name : /tmp/tmpIZkUUJ/540138109343874.mp4_video.264 – Imported with GPAC 0.4.6-DEV-rev3544
Stream #0:1(und): Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp (default)
Metadata:
creation_time : 2013-01-18 03:43:54
handler_name : /tmp/tmpIZkUUJ/540138109343874.mp4_audio.aac – Imported with GPAC 0.4.6-DEV-rev3544
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mpeg4)
Stream #0:1 -> #0:1 (aac -> libmp3lame)
Press [q] to stop, [?] for help
frame= 1773 fps=182 q=9.1 Lsize= 2725kB time=00:00:59.24 bitrate= 376.8kbits/s
video:1694kB audio:926kB subtitle:0 data:0 global headers:0kB muxing overhead 4.021155%

ffmpeg

 

You are good to go now 🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>