Compile FFmpeg on CentOS
2015-08-31 14:14
459 查看
Contents
Get the DependenciesCompilation & Installation
Updating
Reverting changes made by this guide
If You Need Help
Also See
This guide is based on a minimal installation of the latest CentOS release, and will provide a local, non-system installation of FFmpeg with support for several external encoding libraries. These instructions should also work for recent Red Hat Enterprise
Linux (RHEL) and Fedora. This is a non-invasive guide and undoing all steps is simple and is shown at the end of this page.
Get the Dependencies¶
Note: The # indicates that the command should be executed as superuser or root.Get the dependencies. These are required compiling, but you can remove them when you are done if you prefer (exceptmake; it should be installed by default and many things depend on it).
# yum install autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel
In your home directory make a new directory to put all of the source code into:
mkdir ~/ffmpeg_sources
Compilation & Installation¶
Note: If you do not require certain encoders you may skip the relevant section and then remove the appropriate./configure option in FFmpeg. For example, if libvorbis is not needed, then skip that section and then remove--enable-libvorbisfrom the
Install FFmpeg section.
Yasm¶
Yasm is an assembler used by x264 and FFmpeg.cd ~/ffmpeg_sources git clone --depth 1 git://github.com/yasm/yasm.git cd yasm autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make make install make distclean
libx264¶
H.264 video encoder. See theH.264 Encoding Guide for more information and usage examples.
Requires ffmpeg to be configured with --enable-gpl --enable-libx264.
cd ~/ffmpeg_sources git clone --depth 1 git://git.videolan.org/x264 cd x264 ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static make make install make distclean
libx265¶
H.265/HEVC video encoder. See theH.265 Encoding Guide for more information and usage examples.
Requires ffmpeg to be configured with --enable-gpl --enable-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¶
AAC audio encoder.Requires ffmpeg to be configured with --enable-libfdk-aac (and--enable-nonfree if you also included--enable-gpl).
cd ~/ffmpeg_sources git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac cd fdk-aac autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install make distclean
libmp3lame¶
MP3 audio encoder.Requires ffmpeg to be configured with --enable-libmp3lame.
cd ~/ffmpeg_sources 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="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm make make install make distclean
libopus¶
Opus audio decoder and encoder.Requires ffmpeg to be configured with --enable-libopus.
cd ~/ffmpeg_sources git clone git://git.opus-codec.org/opus.git cd opus autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install make distclean
libogg¶
Ogg bitstream library. Required bylibtheora and
libvorbis.
cd ~/ffmpeg_sources 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="$HOME/ffmpeg_build" --disable-shared make make install make distclean
libvorbis¶
Vorbis audio encoder. Requireslibogg.
Requires ffmpeg to be configured with --enable-libvorbis.
cd ~/ffmpeg_sources 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$HOME/ffmeg_build/lib" CPPFLAGS="-I$HOME/ffmpeg_build/include" ./configure --prefix="$HOME/ffmpeg_build" --with-ogg="$HOME/ffmpeg_build" --disable-shared make make install make distclean
libvpx¶
VP8/VP9 video encoder.Requires ffmpeg to be configured with --enable-libvpx.
cd ~/ffmpeg_sources git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git cd libvpx ./configure --prefix="$HOME/ffmpeg_build" --disable-examples make make install make clean
FFmpeg¶
cd ~/ffmpeg_sources git clone --depth 1 git://source.ffmpeg.org/ffmpeg cd ffmpeg PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/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
./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-opencl --enable-libmfx --enable-memalign-hack --enable-gpl --enable-libx265 --extra-cflags=-I/opt/intel/mediasdk/include --extra-cflags=-I/opt/intel/opencl/include --extra-ldflags=-L/opt/intel/mediasdk/lib/lin_x64/ --extra-ldflags=-L/opt/intel/opencl --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs="-lva -lva-drm -lrt -ldl -lstdc++"
遇到x265包找不到 是因为x265 编译成静态链接库 应将off改为on
Compilation is now complete and ffmpeg (also ffprobe, ffserver,lame, andx264) should now be ready to use. The rest of this guide shows how to update or remove FFmpeg.
Tip: Keep the ffmpeg_sources directory and all contents if you intend toupdate as shown below. Otherwise you
can delete this directory.
Updating¶
Development of FFmpeg is active and an occasional update can give you new features and bug fixes. First, remove the old files and then update the dependencies:rm -rf ~/ffmpeg_build ~/bin/{ffmpeg,ffprobe,ffserver,lame,vsyasm,x264,x265,yasm,ytasm} # yum install autoconf automake cmake gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel
Update Yasm¶
cd ~/ffmpeg_sources/yasm make distclean git pull
Then run ./configure, make, and make install as shown in theInstall yasm section.
Update x264¶
cd ~/ffmpeg_sources/x264 make distclean git pull
Then run ./configure, make, and make install as shown in theInstall x264 section.
Update x265¶
cd ~/ffmpeg_sources/x265 rm -rf ~/ffmpeg_sources/x265/build/linux/* hg update cd ~/ffmpeg_sources/x265/build/linux
Then run cmake, make, and make install as shown in theInstall x265 section.
Update libfdk_aac¶
cd ~/ffmpeg_sources/fdk_aac make distclean git pull
Then run ./configure, make, and make install as shown in theInstall libfdk_aac section.
Update libvpx¶
cd ~/ffmpeg_sources/libvpx make clean git pull
Then run ./configure, make, and make install as shown in theInstall libvpx section.
Update FFmpeg¶
cd ~/ffmpeg_sources/ffmpeg make distclean git pull
Then run ./configure, make, and make install as shown in theInstall FFmpeg section.
Reverting changes made by this guide¶
rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffserver,lame,vsyasm,x264,yasm,ytasm} # yum erase autoconf automake cmake gcc gcc-c++ git libtool mercurial nasm pkgconfig zlib-devel hash -r
If You Need Help¶
Feel free to ask your questions at the #ffmpeg IRC channel or theffmpeg-user mailing list.
Also See¶
H.264 Video Encoding GuideAAC Audio Encoding Guide
相关文章推荐
- CentOS利用crontab执行计划任务
- LINUX_egrep及扩展正则表达式
- linux删除符合条件的文件
- LINUX_grep及正则表达式
- GIT在Linux上的安装和使用简介
- linux常用命令总结(转自董的博客)
- linux中mmap系统调用原理分析与实现
- Linux内存管理之mmap详解
- 理解 Linux 配置文件分类和使用
- Linux进程间通信之消息队列(二)
- Linux进程间通信之消息队列(一)
- Linux进程间通信之命名管道
- linux 目录操作
- Linux进程间通信之匿名管道
- Linux进程间通信之信号
- Linux下的硬件驱动——USB设备(上)(驱动配置部分)
- Linux进程间通信之信号量
- Centos如何永久修改系统时间
- Linux进程间通信之共享内存(二)
- Linux进程间通信之共享内存(一)