【Linux】Centos下安装ffmpeg

一、准备工作

1、系统环境:CentOS release 6.9 (Final)

2、安装依赖包

yum install -y autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel

二、安装

如果您不需要特定的编码器,可以在编译ffmpeg的时候不启用

根目录默认为

cd /usr/local/src/

1、Yasm

Ysam是X264和FFmpeg使用的汇编程序。

git clone --depth 1 git://github.com/yasm/yasm.git
cd yasm
autoreconf -fiv
./configure --prefix="$lib/ffmpeg_build" --bindir="$lib/bin"
make
make install
make distclean

2、libx264

libx264 视频编码器。更多说明和用法示例可以参考:https://trac.ffmpeg.org/wiki/Encode/H.264

编译参数:–enable-gpl –enable-libx264

git clone --depth 1 git://git.videolan.org/x264
cd x264
PKG_CONFIG_PATH="$lib/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$lib/ffmpeg_build" --bindir="$lib/bin" --enable-static
make
make install
make distclean

3、libx265

H.265/HEVC 视频编码器。更多说明和用法示例可以参考:https://trac.ffmpeg.org/wiki/Encode/H.265

安装教程:https://bitbucket.org/multicoreware/x265/wiki/Home

编译参数:–enable-gpl –enable-libx265

hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$lib/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install

4、libfdk_aac

AAC 音频编码器。

编译参数:–enable-libfdk-aac (以及 –enable-nonfree 如果你添加了 –enable-gpl的话)

git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

5、libmp3lame

MP3 音频编码器.

编译参数: –enable-libmp3lame

curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$lib/ffmpeg_build" --bindir="$lib/bin" --disable-shared --enable-nasm
make
make install
make distclean

6、libopus

Opus 音频编解码器.

编译参数: –enable-libopus

git clone https://git.xiph.org/opus.git
cd opus
autoreconf -fiv
./configure --prefix="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

7、libogg

Ogg 比特流库.。libtheora and libvorbis需要

curl -O 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="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

8、libvorbis

Vorbis 音频编码器. 需要 libogg

编译参数:–enable-libvorbis

curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
tar xzvf libvorbis-1.3.4.tar.gz
cd libvorbis-1.3.4
LDFLAGS="-L$lib/ffmeg_build/lib" CPPFLAGS="-I$lib/ffmpeg_build/include" ./configure --prefix="$lib/ffmpeg_build" --with-ogg="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

9、libvpx

VP8/VP9 视频编码器.

编译参数: –enable-libvpx.

git clone https://github.com/webmproject/libvpx.git
cd libvpx
./configure --prefix="$lib/ffmpeg_build" --disable-examples
make
make install
make clean

10、FFmpeg

git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure --prefix="$lib/ffmpeg_build" --extra-cflags="-I$lib/ffmpeg_build/include" --extra-ldflags="-L$lib/ffmpeg_build/lib" --bindir="$lib/bin" --pkg-config-flags="--static" --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
make
make install
make distclean
hash -r

至此,编译ffmpeg完成

参考文章

1、ffmpeg安装指南:https://trac.ffmpeg.org/wiki/CompilationGuide

2、ffmpeg git地址:https://github.com/FFmpeg/FFmpeg

posted @ 2019-04-23 20:30  踏雪无痕SS  阅读(970)  评论(0编辑  收藏  举报