Linux之CentOS 6.7 x64上编译安装ffmpeg

摘要

为了在vps上能下载youtube视频我就使用了youtube-dl,但是这个在合并视频的时候需要借助ffmpeg,本来ffmpeg可以yum安装的,但是我嫌弃yum安装版本太旧,就自己上编译安装了。

系统信息

[root@LookBack ~]# getconf LONG_BIT
64
[root@LookBack ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)

yum源信息,这里就不再说epel和rpmforge源的安装了

[root@LookBack ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.us.leaseweb.net
 * extras: mirror.us.leaseweb.net
 * updates: mirror.us.leaseweb.net
仓库标识                                           仓库名称                                                                                 状态
base                                               CentOS-6 - Base                                                                           6,575
epel                                               Extra Packages for Enterprise Linux 6 - x86_64                                           11,766
extras                                             CentOS-6 - Extras                                                                            35
rpmforge                                           RHEL 6 - RPMforge.net - dag                                                               4,718
updates                                            CentOS-6 - Updates                                                                          298
repolist: 23,392
[root@LookBack ~]#

清理一些系统上已有的软件包

yum remove libvpx libogg libvorbis libtheora libx264 x264 ffmpeg yasm -y

更新系统和安装编译必要环境

yum clean all && yum makecache && yum update -y
yum install gcc gcc-c++ automake autoconf libtool nasm git subversion dos2unix -y

编译安装Xvid

wget http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz
tar xf xvidcore-1.3.4.tar.gz
cd xvidcore/build/generic
./configure
make && make install
ldconfig
cd ../../../

编译安装Lame

wget http://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz
tar xf lame-3.99.5.tar.gz
cd lame-3.99.5/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig

编译安装AudioCoding

wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
tar xf faac-1.28.tar.gz
cd faac-1.28/
dos2unix bootstrap && ./bootstrap
dos2unix configure && ./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig && cd ..

Linux之CentOS 6.7 x64上编译安装ffmpeg
如果在编译的时候出现上图中的错误,请注释错误提示的行重新编译即可,如下操作

[root@LookBack ~/faac-1.28]# sed -i '126s@^@//@' common/mp4v2/mpeg4ip.h
[root@LookBack ~/faac-1.28]# make clean && make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig && cd ..

编译安装opencore-amr

wget http://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-0.1.4.tar.gz
tar xf fdk-aac-0.1.4.tar.gz
cd fdk-aac-0.1.4/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig
cd ..

编译安装libogg

wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
tar xf libogg-1.3.2.tar.gz
cd libogg-1.3.2/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig
cd ..

编译安装libvorbis

wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz
tar xf libvorbis-1.3.5.tar.gz
cd libvorbis-1.3.5/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig
cd ..

编译安装libtheora

wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
tar xf libtheora-1.1.1.tar.bz2
cd libtheora-1.1.1/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig
cd ..

编译安装Aacenc

wget http://sourceforge.net/projects/opencore-amr/files/vo-aacenc/vo-aacenc-0.1.3.tar.gz
tar xf vo-aacenc-0.1.3.tar.gz
cd vo-aacenc-0.1.3/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig
cd ..

编译安装yasm

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xf yasm-1.3.0.tar.gz
cd yasm-1.3.0/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
cd .. 

编译安装Libvpx

git clone https://chromium.googlesource.com/webm/libvpx.git
cd libvpx/
./configure
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
cd ..

配置lib

export LD_LIBRARY_PATH=/usr/local/lib/
echo /usr/local/lib >> /etc/ld.so.conf.d/custom-libs.conf
ldconfig

编译安装x264

git clone git://git.videolan.org/x264.git
cd x264/
./configure --enable-static
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
ldconfig
cd ..

编译安装ffmpeg

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="/usr/local/ffmpeg_build" --extra-cflags="-I/usr/local/ffmpeg_build/include" --extra-ldflags="-L/usr/local/ffmpeg_build/lib" --bindir="/usr/local/bin" --extra-libs=-ldl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libvo-aacenc --enable-libxvid --disable-ffplay --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads
echo $?
make -j `awk '/processor/{i++}END{print i}' /proc/cpuinfo` && make install
cd ..

验证安装

[root@LookBack ~]# which ffmpeg
/usr/local/bin/ffmpeg
[root@LookBack ~]# ffmpeg
ffmpeg version N-75247-g1d2beb6 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
  configuration: --prefix=/usr/local/ffmpeg_build --extra-cflags=-I/usr/local/ffmpeg_build/include --extra-ldflags=-L/usr/local/ffmpeg_build/lib --bindir=/usr/local/bin --extra-libs=-ldl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libvo-aacenc --enable-libxvid --disable-ffplay --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  1.100 / 57.  1.100
  libavformat    57.  0.100 / 57.  0.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  1.100 /  6.  1.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

Linux之CentOS 6.7 x64上编译安装ffmpeg

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

lookback

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: