Centos搭建ffmpeg环境

1. yum 安装ffmpeg 依赖软件

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

2、安装ffmpeg的功能模块

下面这些功能模块是可以选择的,当需要ffmpeg实现这些功能时,就可以选择安装或者不安装,因为我需要实现的是mp4转m3u8格式功能,必须增加libx264模块

Yasm :yasm是x264和ffmpeg必须要依赖的模块
mkdir  -p  /data/tools/ffmpeg_sources
cd /ffmpeg_sources
git clone --depth 1 git://github.com/yasm/yasm.git
cd yasm
autoreconf -fiv
./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/bin"
make
make install
make distclean

 

libx264:
cd /data/tools/ffmpeg_sources
git clone https://code.videolan.org/videolan/x264.git
cd x264

PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/usr/local/ffmpeg_build" --bindir="/usr/local/bin" --enable-static --disable-asm
make
make install
make distclean

 

libmp3lame
cd /data/tools/ffmpeg_sources
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="/usr/local/ffmpeg_build" --bindir="/usr/local/bin" --disable-shared --enable-nasm
make
make install
make distclean

 

libopus
cd /data/tools/ffmpeg_sources
git clone git://git.opus-codec.org/opus.git
或者
git clone https://github.com/xiph/opus.git cd opus autoreconf -fiv ./configure --prefix="/usr/local/ffmpeg_build" --disable-shared
make
make install
make distclean

 

libogg
 wget  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="/usr/local/ffmpeg_build" --disable-shared
make
make install
make distclean

 

libvorbis
cd /data/tools/ffmpeg_sources
wget 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/usr/local/ffmeg_build/lib" CPPFLAGS="-I/usr/local/ffmpeg_build/include" ./configure --prefix="/usr/local/ffmpeg_build" --with-ogg="/usr/local/ffmpeg_build" --disable-shared
make
make install
make distclean

 

freetype
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.bz2
tar -jxvf freetype-2.10.0.tar.bz2
cd freetype-2.10.0/
PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/usr/local/ffmpeg_build"
make
make install
make distclean

 

libxml2

wget http://xmlsoft.org/sources/libxml2-2.9.10.tar.gz
tar -zxvf libxml2-2.9.10.tar.gz cd libxml2-2.9.10/ LDFLAGS="-L/usr/local/ffmeg_build/lib" CPPFLAGS="-I/usr/local/ffmpeg_build/include" ./configure --prefix="/usr/local/ffmpeg_build"
make ; make install

 

fontconfig

wget https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.9.92.tar.gz
tar -zxvf fontconfig-2.9.92.tar.gz
cd fontconfig-2.9.92/
PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/usr/local/ffmpeg_build" --enable-libxml2 make ; make install

 

设置环境变量:
cat /etc/profile
最后一行添加
export PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig"

 

注意:
编译完后发现依然还是产生错误:ERROR: libass not found using pkg-config
从config.log文件的最后看出来,是pk-config这个工具在查找一个*.pc的文件
 

 

 

FFmpeg
git clone --depth 1 http://source.ffmpeg.org/git/ffmpeg.git  
cd ffmpeg
PKG_CONFIG_PATH="/usr/local/ffmpeg_build/lib/pkgconfig" ./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" --pkg-config-flags="--static" --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libx264 --enable-libfontconfig --enable-zlib --enable-libfreetype

make
make install
make distclean
hash -r

 

 

 
Libraries:
SDL 2.0.6 https://libsdl.org
bzip2 1.0.6 http://bzip.org/
Fontconfig 2.12.6 http://freedesktop.org/wiki/Software/fontconfig
GnuTLS 3.5.15 http://gnutls.org
libiconv 1.15 http://gnu.org/software/libiconv/
libass 0.13.7 https://github.com/libass/libass
libbluray 20171011-b5216ad http://videolan.org/developers/libbluray.html
FreeType 2.8 http://freetype.sourceforge.net
LAME 3.100 http://lame.sourceforge.net
OpenJPEG 2.3.0 https://github.com/uclouvain/openjpeg
Opus 1.2.1 http://opus-codec.org
shine 3.1.1 https://github.com/savonet/shine
Snappy 1.1.7 https://github.com/google/snappy
libsoxr 20160605-5fa7eeb http://sourceforge.net/projects/soxr
Theora 1.1.1 http://theora.org
TwoLAME 0.3.13 http://twolame.org
vpx 1.6.1 http://webmproject.org
WavPack 5.1.0 http://wavpack.com
WebP 0.6.0 https://developers.google.com/speed/webp
x264 20170626-ba24899 http://videolan.org/developers/x264.html
x265 20171009-0e168bd https://bitbucket.org/multicoreware/x265/wiki/Home
libxml2 2.9.6 http://xmlsoft.org
z.lib 20171013-4166d55 https://github.com/sekrit-twc/zimg
XZ Utils 5.2.3 http://tukaani.org/xz
zlib 1.2.11 http://zlib.net
GMP 6.1.2 https://gmplib.org
vid.stab 20170830-afc8ea9 http://public.hronopik.de/vid.stab
Vorbis 1.3.5 http://vorbis.com
libmfx 1.23 https://software.intel.com/en-us/media-sdk

 

参考:

https://www.jianshu.com/p/5194a05a3a62?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
https://blog.csdn.net/m0_38059843/article/details/78366428
 
posted @ 2022-01-24 15:07  fengjian1585  阅读(410)  评论(0编辑  收藏  举报