How to install FFMPEG in linux | 15 modules (NASM, YASM, x265)
FFMPEG Installation in linux
How to convert your videos using FFmpeg?
How to make ffmpeg run as ffmpeg command?
How to check ffmpeg is installed or not ?
The final step to install ffmpeg?
How to install Libvpx?
How to install x265?
How to install x264?
How to install libvorbis?
How to install Libopus?
How to install Libmp2lame?
How to install libfdk_aac?
How to install Libogg?
How to install YASM?
How to install NASM?
How to install the latest version of Nasm?
How to install FFmpeg in Linux ?
Initially, it was very frustrating installing FFmpeg on the server but after spending 2 days of hard work finally achieved it.
FFmpeg is a very useful command. It provides image, video and document conversion facility and also helps to edit them.
I have tried all methods existing on the internet and finally providing you the best solution:
Let’s start with its installation
First, we need to create the environment so that there should not be any confusion
sudo su mkdir ~/ffmpeg_sources
That will be created as cd /root/ffmpeg_sources
cd /ffmpeg_sources
For FFmpeg, we need different libraries for video conversion and audio conversion and these libraries run compiler “Nasm”. Nasm is needed to compile and install libraries. I suggest installing nasm latest version (currently the latest stable version is 2.31).
How to install the latest version of Nasm
Click here to install latest and standard way to install Nasm.
You need to install one more assembler which is very important “Yasm”
Follow the steps for Yasm installation
cd ~/ffmpeg_sources curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar xzvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make make install
Let’s now start libraries installation for ffmpeg
Basic Libraries
Libogg
Bitstream Library. Required by vorbis and theora.
cd ~/ffmpeg_sources curl -O -L http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz tar xzvf libogg-1.3.2.tar.gz cd libogg-1.3.2 ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install
For Audio conversion and Editing, we need
libfdk_aac
Audio encoder ( AAC requires –enalbe-nonfree and –enable-gpl )
cd ~/ffmpeg_sources git clone --depth 1 https://github.com/mstorsjo/fdk-aac cd fdk-aac autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install
Libmp2lame
Mp3 audio encoder
cd ~/ffmpeg_sources curl -O -L http://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz tar xzvf lame-3.100.tar.gz cd lame-3.100 ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm make make install
Libopus
Audio encoder and decoder
cd ~/ffmpeg_sources curl -O -L https://archive.mozilla.org/pub/opus/opus-1.2.tar.gz tar xzvf opus-1.2.tar.gz cd opus-1.2 ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install
Libvorbis
Audio encoder. First, install ogg and then Vorbis
cd ~/ffmpeg_sources curl -O -L http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz tar xzvf libvorbis-1.3.5.tar.gz cd libvorbis-1.3.5 ./configure --prefix="$HOME/ffmpeg_build" --with-ogg="$HOME/ffmpeg_build" --disable-shared make make install
For video conversion and editing we need
cd ~/ffmpeg_sources git clone --depth 1 http://git.videolan.org/git/x264 cd x264 PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static make make install
Installation path will be /root/ffmpeg_build and /root/bin
Note: Sometime it will show that you need to install nasm >= 2.13 version.
Follow these steps to solve this issue
yum remove nasm && harh -r
Click here to install the latest version of nasm and more.
x265
This is also video encoder
cd ~/ffmpeg_sources hg clone https://bitbucket.org/multicoreware/x265 cd ~/ffmpeg_sources/x265/build/linux cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source make make install
Libvpx
VP8/VP9 video encoder and decoder
cd ~/ffmpeg_sources git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git cd libvpx ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm make make install
FFmpeg installation final step
cd ~/ffmpeg_sources curl -O -L https://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" \ --extra-libs=-lpthread \ --bindir="$HOME/bin" \ --enable-gpl \ --enable-libfdk_aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libvorbis \ --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ --enable-nonfree make make install hash -r
OR After installation of required libraries. We can also install FFmpeg with enable option with the respectively installed libraries. Eample If we just need to install ffmpeg for audio conversion
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" \ --extra-libs=-lpthread \ --bindir="$HOME/bin" \ --enable-libfdk_aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libvorbis \ make make install hash -r
How to check FFmpeg is installed or not
Command to check ffmpeg and installed libraries
ffmpeg /root/bin/ffmpeg ffmpeg -h
How to make ffmpeg run as ffmpeg command
cd /usr/bin vim ffmpeg #!/bin/bash /root/bin/ffmpeg
Now try to convert your videos,
Try with these examples
wget https://techouse.co.in/wp-content/uploads/2017/08/How-to-make-the-terminal-transparent-in-Linux-centos-7ubuntu.mp4?_=1 or curl -O https://techouse.co.in/wp-content/uploads/2017/08/How-to-make-the-terminal-transparent-in-Linux-centos-7ubuntu.mp4?_=1 ffmpeg -i How-to-make-the-terminal-transparent-in-Linux-centos-7ubuntu.mp4 convert.webm ffmpeg -i How-to-make-the-terminal-transparent-in-Linux-centos-7ubuntu.mp4 -vf drawtext="fontfile=/usr/share/fonts/lyx/cmmi10.ttf: \ text='Created by Chirag Thank You': fontcolor=white: fontsize=24: box=1: [email protected]: \ boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2" -codec:a copy wiz.mp4
For any query comment below.
Thank You