Part4 - Installing FFMPEG with Extra Encoding and Decoding Libraries

Print

Installing FFmpeg:

I would like to add some extra libraries to FFMPEG so I will run all the commands below to install them. I recommend you to do the same. 


sudo apt-get update


sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \ libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \ libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev

sudo apt-get update
sudo apt-get install yasm sudo apt-get install libx264-dev sudo apt-get install libfdk-aac-dev sudo apt-get install libvo-aacenc-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libopus-dev



Here we are installing Libx265 Library

 

mkdir ~/ffmpeg_sources
sudo apt-get install cmake mercurial
cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install
make distclean




Here We install Libvpx



cd ~/ffmpeg_sources
wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.6.0.tar.bz2
tar xjvf libvpx-1.6.0.tar.bz2
cd libvpx-1.6.0
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests
PATH="$HOME/bin:$PATH" make
make install
make clean


#FFMpeg

 

cd ~/ffmpeg_sources 
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ --prefix="$HOME/ffmpeg_build" \ --pkg-config-flags="--static" \ --extra-cflags="-I$HOME/ffmpeg_build/include" \ --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ --bindir="$HOME/bin" \ --enable-gpl \ --enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libtheora \ --enable-libvorbis \ --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ --enable-nonfree PATH="$HOME/bin:$PATH" make
make install
make distclean
hash -r

 

 

If you want the ffmpeg command to just work from anywhere:
• Log in and log out • Or run source 

~/.profile


sudo apt install ffmpeg

Let's test FFMPEG if it works...

Download a mp4 file from internet name it as sample.mp4. Then run ffmpeg like below and convert sample.mp4 to mkv or flv extension and check if they are created.

ffmpeg -i /home/nginxadmin/Downloads/sample.mp4 /home/nginxadmin/Downloads//output.mkv

OR

ffmpeg -i /home/nginxadmin/Downloads/sample.mp4 /home/nginxadmin/Downloads//output.flv  

 

 

To list all installed codecs:

ffmpeg -codecs

 

To list all installed encoders:

ffmpeg -encoders

 

To list all installed decoders:

ffmpeg -decoders

 

We installed FFMPEG, now we can configure Nginx Server for HLS Streaming