FFmpeg 安装

FFmpeg 安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#1. 安装依赖包
yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c ++ git libtool make mercurial pkgconfig zlib-devel

#2. 创建 ffmpeg_sources 目录
mkdir /ffmpeg_sources

#3. NASM - An assembler used by some libraries
cd /ffmpeg_sources
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz
tar -zxvf nasm-2.14.02.tar.gz
cd nasm-2.14.02
./autogen.sh
./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/ffmpeg_build/bin"
make
make install

#4. 添加环境变量生效的路径
vi /etc/profile
export PATH=/usr/local/ffmpeg_build/bin:$PATH
wq
source /etc/profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#5. YASM - An assembler used by some libraries
cd /ffmpeg_sources
wget 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="/usr/local/ffmpeg_build" --bindir="/usr/local/ffmpeg_build/bin"
make
make install

#6. libx264 - H.264 video encoder (Requires ffmpeg to be configured with --enable-gpl --enable-libx264)
cd /ffmpeg_sources
wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar -xjvf last_x264.tar.bz2
cd x264-snapshot-20190128-2245
PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/ffmpeg_build/bin" --enable-static
make
make install

#7. lib265 - H.265/HEVC video encoder (Requires ffmpeg to be configured with --enable-gpl --enable-libx265)
cd /ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install

#8. libfdk_aac - AAC audio encoder (Requires ffmpeg to be configured with --enable-libfdk_aac [and --enable-nonfree if you also included --enable-gpl])
cd /ffmpeg_sources
wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.0.tar.gz
tar -zxvf fdk-aac-2.0.0.tar.gz
cd fdk-aac-2.0.0
autoreconf -fiv
./configure --prefix="/usr/local/ffmpeg_build" --disable-shared
make
make install

#9. libmp3lame - MP3 audio encoder (Requires ffmpeg to be configured with --enable-libmp3lame)
cd /ffmpeg_sources
wget https://iweb.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar -zxvf lame-3.100.tar.gz
cd lame-3.100
./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/ffmpeg_build/bin" --disable-shared --enable-nasm
make
make install

#10. libopus - Opus audio decoder and encoder (Requires ffmpeg to be configured with --enable-libopus)
cd /ffmpeg_sources
wget https://archive.mozilla.org/pub/opus/opus-1.3.tar.gz
tar -zxvf opus-1.3.tar.gz
cd opus-1.3.1
./configure --prefix="/usr/local/ffmpeg_build" --disable-shared
make
make install

#11. libogg - Ogg bitstream library
cd /ffmpeg_sources
wget https://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.gz
tar -zxvf libogg-1.3.3.tar.gz
cd libogg-1.3.3
./configure --prefix="/usr/local/ffmpeg_build" --disable-shared
make
make install

#12. libvorbis - Vorbis audio encoder (Requires ffmpeg to be configured with --enable-libvorbis)
cd /ffmpeg_sources
wget https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.tar.gz
tar xzvf libvorbis-1.3.6.tar.gz
cd libvorbis-1.3.6
./configure --prefix="/usr/local/ffmpeg_build" --with-ogg="/usr/local/ffmpeg_build" --disable-shared
make
make install

#13. libvpx - VP8/VP9 video encoder and decoder (Requires ffmpeg to be configured with --enable-libvpx)
cd /ffmpeg_sources
wget https://github.com/webmproject/libvpx/archive/v1.7.0/libvpx-1.7.0.tar.gz
tar -zxvf libvpx-1.7.0.tar.gz
cd libvpx-1.7.0
./configure --prefix="/usr/local/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make
make install

#14. FFmpeg
cd /ffmpeg_sources
wget https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar -xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="/usr/local/ffmpeg_build/bin:$PATH" PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/usr/local/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I /usr/local/ffmpeg_build/include" --extra-ldflags="-L /usr/local/ffmpeg_build/lib" --extra-libs=-lpthread --extra-libs=-lm --bindir="/usr/local/ffmpeg_build/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

参考资料

Compile FFmpeg on CentOS

0%