ffmpeg编译安装

版权声明:Don't trouble trouble until trouble troubles you. https://blog.csdn.net/JOJOY_tester/article/details/85711808

ffmpeg是什么

 FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码库libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多code都是从头开发的。

FFmpeg在Linux平台下开发,但它同样也可以在其它操作系统环境中编译运行,包括Windows、Mac OS X等。这个项目最早由Fabrice Bellard发起,2004年至2015年间由Michael Niedermayer主要负责维护。许多FFmpeg的开发人员都来自MPlayer项目,而且当前FFmpeg也是放在MPlayer项目组的服务器上。项目的名称来自MPEG视频编码标准,前面的"FF"代表"Fast Forward"。

一、安装cmake

[root@centos7 ~]# cmake --version

cmake version 2.8.12.2

[root@centos7 cmake-3.5.0]# yum remove cmake -y

[root@centos7 ffmpeg]# tar -xvf cmake-3.5.0.tar.gz

[root@centos7 cmake-3.5.0]# cd cmake-3.5.0 && ./configure

[root@centos7 cmake-3.5.0]# echo $?

0

[root@centos7 cmake-3.5.0]# make && make install

[root@centos7 cmake-3.5.0]# echo $?

0

[root@centos7 bin]# cp /usr/local/bin/cmake /usr/bin/

[root@centos7 bin]# ./cmake --version

cmake version 3.5.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

二、安装yasm库(提高编解码效率)

[root@centos7 ffmpeg]# tar xvf yasm-1.3.0.tar.gz

[root@centos7 yasm-1.3.0]# ./configure

[root@centos7 yasm-1.3.0]# make && make install

三、安装h246编解码库

[root@centos7 ffmpeg]# yum install -y bzip2

[root@centos7 ffmpeg]# tar -xvf last_x264.tar.bz2

[root@centos7 x264-snapshot-20160319-2245]# ./configure --enable-shared

[root@centos7 x264-snapshot-20160319-2245]# make && make install

相关文件位置:

h264库的头文件在/usr/local/include

动静态库在/usr/local/lib

x264.pc库的配置文件在/usr/local/lib/pkgconfig

四、安装 h265 编解码库

[root@centos7 x265_1.9]# tar -xvf x265_1.9.tar.gz

[root@centos7 linux]# cd /root/ffmpeg/x265_1.9/build/linux

运行脚本:

[root@centos7 linux]# sh make-Makefiles.bash

执行时会弹出界面选项, 按'c'再按'g'键保存退出

安装:

[root@centos7 linux]# make && make install

相关文件位置:

h265库的头文件在/usr/local/include

五、安装 ffmpeg

[root@centos7 ffmpeg]# tar xvf ffmpeg-3.0.tar.bz2

设置环境变量

[root@centos7 ffmpeg-3.0]# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

(这个是临时的,如果需要永久生效需要写进/etc/profile里面)

安装ffmpeg

[root@centos7 ffmpeg-3.0]# ./configure --disable-debug --enable-libx264 --enable-libx265 --enable-gpl --enable-shared

[root@centos7 ffmpeg-3.0]# make && make install

复制文件

[root@centos7 lib]# cp /usr/local/lib/libx* /lib64/

[root@centos7 lib]# cp /usr/local/lib/libav* /lib64/

[root@centos7 lib]# cp /usr/local/lib/libsw* /lib64/

[root@centos7 lib]# cp /usr/local/lib/libpostproc* /lib64/

可能出现的问题:

在configure的时候

有报错:enabled program:

解决:是否有ffplay(没有的话,yum install SDL, 后再重新configure

需要使用的安装包:

官网:http://ffmpeg.org/
百度云下载地址:https://pan.baidu.com/s/1wlMFUV6olcDgVM5bMG0xRQ 密码:tcnn

cmake-3.5.0.tar.gz

ffmpeg-3.0.tar.bz2

last_x264.tar.bz2

x265_1.9.tar.gz

yasm-1.3.0.tar.gz

猜你喜欢

转载自blog.csdn.net/JOJOY_tester/article/details/85711808