Linux编译FFMPEG+X264

注意

以下每一步都安装后都需要配置bash_profile里面

PATH=$PATH:$HOME/bin
PATH=$PATH:/usr/local/lib/xxx/bin
  • xvid可以略过 牺牲性能

yasm:
git clone git://github.com/yasm/yasm.git
cd yasm
 ./autogen.sh
./configure --perfix=/home/video/usr/loca/yasm
make
make install
xvid:
wget http://downloads.xvid.org/downloads/xvidcore-1.1.0.tar.gz
tar zvxf xvidcore-1.1.0.tar.gz
cd xvidcore-1.1.0/build/generic
./configure --prefix=/home/video/usr/loca/xvid
make
make install
x264

http://download.videolan.org/x264/snapshots/ 下载
x264-snapshot-20151208-2245.tar.bz2

 tar -xjf  x264-snapshot-20151208-2245.tar.bz2 
./configure --prefix=/home/video/usr/local/x264 --enable-shared --enable-static --enable-yasm
make
make install
ffmpeg

http://www.ffmpeg.org/download.html

xz -d ffmpeg.tar.sz
tar -xvf  ***.tar

./configure --prefix=/home/video/usr/local/ffmpeg --enable-libmp3lame --enable-libvorbis --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libx264 --enable-libxvid --enable-postproc --enable-ffserver --enable-ffplay --enable-shared --extra-cflags=-I/home/video/usr/local/x264/include --extra-ldflags=-L/home/video/usr/local/x264/lib --extra-cflags=-I/home/video/usr/local/lame/include --extra-ldflags=-L/home/video/usr/local/lame/lib --extra-cflags=-I/home/video/usr/local/xvid/include  --extra-ldflags=-L/home/video/usr/local/xvid/lib
make
make install

最终 配置环境变量及库路径

首先是命令的路径,编辑/etc/profile

export PATH=$PATH:/usr/local/ffmpeg/bin:/usr/local/yasm/bin:/usr/local/x264/bin

其次是链接库路径,编辑/etc/ld.so.conf

/usr/local/ffmpeg/lib
/usr/local/x264/lib

之后执行

sudo ldconfig

编译器默认搜索路径并不包含这两个目录,虽然这里设置了配置文件,但在编译的时候也会报错,仍然需要
-L/usr/local/ffmpeg/lib -L/usr/local/x264/lib来链接库
为了简化,可以直接将
/usr/local/ffmpeg/lib
/usr/local/x264/lib这两个目录中的.so文件直接考到/usr/local/lib目录,>一劳永逸

你可能感兴趣的:(Linux编译FFMPEG+X264)