-
-
Save freedomlang/6cac7a75f33bdb1abf0dccf3bd4fa753 to your computer and use it in GitHub Desktop.
Compile ffmpeg in CentOS 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "`/usr/bin/whoami`" != "root" ]; then | |
echo "You need to execute this script as root." | |
exit 1 | |
fi | |
############################################################################### | |
# ffmpeg installer for centos 7 | |
# based on instructions at https://trac.ffmpeg.org/wiki/CompilationGuide/Centos | |
############################################################################### | |
yum install -y autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel | |
mkdir ~/ffmpeg_sources | |
# NASM | |
cd ~/ffmpeg_sources | |
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 | |
tar xjvf nasm-2.14.02.tar.bz2 | |
cd nasm-2.14.02 | |
./autogen.sh | |
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" | |
make | |
make install | |
# Yasm | |
cd ~/ffmpeg_sources | |
curl -O -L https://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 | |
# libx264 | |
cd ~/ffmpeg_sources | |
git clone --depth 1 https://code.videolan.org/videolan/x264.git | |
cd x264 | |
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static | |
make | |
make install | |
# libx265 | |
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 | |
# libfdk_aac | |
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 | |
# libmp3lame | |
cd ~/ffmpeg_sources | |
curl -O -L https://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 | |
cd ~/ffmpeg_sources | |
curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz | |
tar xzvf opus-1.3.1.tar.gz | |
cd opus-1.3.1 | |
./configure --prefix="$HOME/ffmpeg_build" --disable-shared | |
make | |
make install | |
# libvpx | |
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 itself | |
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 \ | |
--extra-libs=-lm \ | |
--bindir="$HOME/bin" \ | |
--enable-gpl \ | |
--enable-libfdk_aac \ | |
--enable-libfreetype \ | |
--enable-libmp3lame \ | |
--enable-libopus \ | |
--enable-libvpx \ | |
--enable-libx264 \ | |
--enable-libx265 \ | |
--enable-nonfree | |
make | |
make install | |
@alil0rd Looks like you are running CentOS 6? If it is, this script won't work for it, it is CentOS 7 only(maybe including 8).
This is:
`
[root@ip154 ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your answer. Line one got me this error:
`
[root@ip154 nasm-2.14.02]# yum install -y autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 33 kB 00:00:00
base | 3.6 kB 00:00:00
http://mirror.centos.org/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
One of the configured repositories failed (CentOS-6 – Base),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
failure: repodata/repomd.xml from centos: [Errno 256] No more mirrors to try.
http://mirror.centos.org/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
`