docker下centos7编译安装ffmpeg

1.安装基础命令

docker下精简版centos没有make等命令,先安装:

yum -y install gcc automake autoconf libtool make

yum install gcc gcc-c++

当然也没有wget

yum install -y wget

还有vim

yum install -y vim

虽然这些不是必须的,但是有会方便很多

2.安装nasm

wget https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz

tar xvf nasm-2.13.03.tar.gz

cd nasm-2.13.03

./configure

make

make install

3.安装yasm

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

tar zxvf yasm-1.3.0.tar.gz

cd yasm-1.3.0

./configure

make

make install

4.安装x264

下载地址: http://www.videolan.org/developers/x264.html
下载的包为:last_x264.tar.bz2

tar -jxvf last_x264.tar.bz2 

cd x264-snapshot-20161101-2245 

./configure --enable-shared 

make 

make install

加入环境变量,执行:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

5.安装ffmpeg

先去官网下载:https://www.ffmpeg.org/download.html

tar -jxvf ffmpeg-4.2.1.tar.bz2

cd ffmpeg-4.2.1

./configure –enable-shared –prefix=/usr/local/ffmpeg –enable-gpl –enable-libx264

make

make install

配置:

vim /etc/ld.so.conf

打开后加入以下两行:
/usr/local/ffmpeg/lib
/usr/local/lib

让配置生效
ldconfig

创建链接(全局的快捷方式,加入后可以先jdk一样在任意目录下java -version等操作)

ln -s /usr/local/ffmpeg/bin/ffmpeg /usr/local/bin/ 

ln -s /usr/local/ffmpeg/bin/ffprobe /usr/local/bin/ 

ln -s /usr/local/ffmpeg/bin/ffserver /usr/local/bin/

6.测试

输入ffmpeg -version

返回结果:
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
configuration: --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

有出现什么问题请留言,我基本都在

你可能感兴趣的:(linux)