【Linux】Centos下安装ffmpeg

1、准备工做

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

二、安装依赖包c++

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

2、安装

若是您不须要特定的编码器,能够在编译ffmpeg的时候不启用git

根目录默认为github

cd /usr/local/src/

一、Yasm

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

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

二、libx264

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

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

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

三、libx265

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

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

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

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

四、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

五、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

六、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

七、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

八、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

九、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

十、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完成

参考文章

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

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

相关文章
相关标签/搜索