How to compile static FFmpeg 3.0 on CentOS 5.11 cPanel WHM

Post Reply
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

How to compile static FFmpeg 3.0 on CentOS 5.11 cPanel WHM

Post by tong »

https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
http://johnvansickle.com/ffmpeg/

1. Git download sources method didn't work well. Files didn't same as .tar.gz.

2. Yasm is required for libx264, libx265 and FFmpeg.

3. CMake 2.8.8+ is required to complie libx265.

4. Make sure that you have all tools.

Code: Select all

yum install cmake gcc gcc-c++ libtool make nasm pkgconfig zlib-devel
5. We want only static libraries (.a). We don't need dynamically linked shared object libraries (.so).
So we need to add an options --disable-shared and/or --enable-static.
Sometime if FFmpeg see the .so in the system, it will complie as dynamically linked as default.

There are two Linux C/C++ library types which can be created:

1. Static libraries (.a): Library of object code which is linked with, and becomes part of the application.

2. Dynamically linked shared object libraries (.so): It can be used in two ways.

2.1 Dynamically linked at run time but statically aware. The libraries must be available during compile/link phase.
The shared objects are not included into the executable component but are tied to the execution.

2.2 Dynamically loaded/unloaded and linked during execution by using the dynamic linking loader system functions.
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

Re: How to compile FFmpeg 3.0 on CentOS 5.11

Post by tong »

Initialize

Code: Select all

export TMPDIR="$HOME/tmp"
export PATH="$HOME/ffmpeg/bin:$PATH"
export PKG_CONFIG_PATH="$HOME/ffmpeg/lib/pkgconfig"

mkdir -p ~/tmp
mkdir -p ~/ffmpeg/src
Since we need to run our own prefer Yasm and CMake binaries, $HOME/ffmpeg/bin should be come first in $PATH.
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

Re: How to compile FFmpeg 3.0 on CentOS 5.11

Post by tong »

libmp3lame is MP3 audio encoder

Nasm is required.

Code: Select all

cd ~/ffmpeg/src
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xvfz lame-3.99.5.tar.gz
cd ~/ffmpeg/src/lame-3.99.5
./configure --prefix="$HOME/ffmpeg" --disable-shared --enable-nasm
make
make install
make distclean
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

Re: How to compile FFmpeg 3.0 on CentOS 5.11

Post by tong »

libfdk_aac is AAC audio encoder

Code: Select all

cd ~/ffmpeg/src
wget http://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.4.tar.gz
tar xvfz fdk-aac-0.1.4.tar.gz
cd ~/ffmpeg/src/fdk-aac-0.1.4
./configure --prefix="$HOME/ffmpeg" --disable-shared
make
make install
make distclean
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

Re: How to compile FFmpeg 3.0 on CentOS 5.11

Post by tong »

Yasm is an assembler used by libx264, libx265 and ffmpeg

Code: Select all

cd ~/ffmpeg/src
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xvfz yasm-1.3.0.tar.gz
cd ~/ffmpeg/src/yasm-1.3.0
./configure --prefix="$HOME/ffmpeg"
make
make install
make distclean

CMake v2.8.8+ is required to complie libx265

Code: Select all

cd ~/ffmpeg/src
wget --no-check-certificate https://cmake.org/files/v2.8/cmake-2.8.8.tar.gz
tar xvfz cmake-2.8.8.tar.gz
cd ~/ffmpeg/src/cmake-2.8.8
./configure --prefix="$HOME/ffmpeg"
make
make install
make clean
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

Re: How to compile FFmpeg 3.0 on CentOS 5.11

Post by tong »

libx264 is H.264 video encoder

Yasm is required.

Code: Select all

cd ~/ffmpeg/src
mkdir -p x264
wget -O x264.tar.bz2 http://download.videolan.org/videolan/x264/snapshots/last_stable_x264.tar.bz2
tar xvfj x264.tar.bz2 -C x264 --strip-components 1
cd ~/ffmpeg/src/x264
./configure --prefix="$HOME/ffmpeg" --enable-static
make
make install
make distclean
We need options:
--enable-static

Defaults:
--disable-shared
--disable-static

Suggest to add options:
--disable-opencl
--disable-cli
--disable-avs
--disable-ffms
--disable-gpac
--disable-lavf
--disable-lsmash
--disable-swscale
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

Re: How to compile FFmpeg 3.0 on CentOS 5.11

Post by tong »

libx265 is H.265/HEVC video encoder

CMake v2.8.8+ and Yasm are required.

Code: Select all

cd ~/ffmpeg/src
wget http://download.videolan.org/videolan/x265/x265_1.9.tar.gz
tar xvfz x265_1.9.tar.gz
cd ~/ffmpeg/src/x265_1.9/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg" -DENABLE_SHARED:bool=off ../../source
make
make install
make clean
We need options:
-DENABLE_SHARED:bool=off (Equal to --disable-shared)

Another download link:
wget -O x265_1.9.tar.gz http://bitbucket.org/multicoreware/x265/downloads/x265_1.9.tar.gz
tong
Site Admin
Posts: 2387
Joined: Fri 01 May 2009 8:55 pm

Re: How to compile FFmpeg 3.0 on CentOS 5.11

Post by tong »

FFmpeg

Yasm is required.

Code: Select all

cd ~/ffmpeg/src
wget http://ffmpeg.org/releases/ffmpeg-3.0.tar.gz
tar xvfz ffmpeg-3.0.tar.gz
cd ~/ffmpeg/src/ffmpeg-3.0
./configure --prefix="$HOME/ffmpeg" \
--pkg-config-flags="--static" \
--extra-ldflags="-ldl" \
--disable-ffplay --disable-ffprobe --disable-ffserver \
--enable-gpl --enable-version3 --enable-nonfree \
--enable-gray \
--enable-libmp3lame --enable-libfdk-aac --enable-libx264 --enable-libx265 \
--extra-version="Tong_Narak"
make
make install
make distclean
We need options:
--pkg-config-flags="--static" (To build static FFmpeg executable)
--extra-ldflags="-ldl" (To avoid libx264 error while checking external library opencl)

If libx264 was complied as dynamically linked shared object library (libx264.so), we have to use options:

--pkg-config-flags="--static"
--extra-cflags="-I$HOME/ffmpeg/include -static"
--extra-ldflags="-L$HOME/ffmpeg/lib -static"

Defaults:
--enable-static tell a complier to create the static libraries (libav*.a).
We can be combine FFmpeg API in the other application.

--disable-shared tell a complier not to create the dynamically linked shared object libraries (libav*.so).
These shared object (external) libraries can be load and use FFmpeg API by the other application at runtime.

These 2 options doesn't complie FFmpeg as standalone static executable.
Post Reply