在CentOS 7.4下构建 ffmpeg 开发环境

			              	┌────────────────────────────────────┐
			              	│RELEASE NOTES for FFmpeg 4.4 "Rao"  │
			             	└────────────────────────────────────┘
			
			                        基于 FFMPEG 4.4 编译

直接安装

centos7

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

centos6

sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
sudo yum install ffmpeg ffmpeg-devel -y

ffmpeg -h
ffmpeg -i input.mp4 output.avi

编译安装

1.下载源码

wget http://www.ffmpeg.org/download.html#releases

2.依赖安装 并卸载冗余

yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel cmake hg numactl numactl-devel freetype freetype-devel freetype-demos
yum remove ffmpeg ffmpeg-devel nasm -y

2.安装文件夹

mkdir ffmpeg
mkdir needed

3.前置安装,否则编译报错

ERROE libfdk_aac not found问题↓
libfdk_aac安装:

cd needed
wget  https://udomain.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-2.0.2.tar.gz
cd fdk-aac-2.0.2/
./configure
make && make install

3.编译ffmpeg(安装目录prefix自定义,不需要则会到默认目录):

wget http://www.ffmpeg.org/download.html#releases
tar -xvf ffmpeg-4.4.tar.gz
cd ffmpeg-4.4
./configure --prefix="/usr/local/dujnLib/ffmpeg"
make && make install

4.结果:

[root@localhost ffmpeg]# pwd
/usr/local/dujnLib/ffmpeg
[root@localhost ffmpeg]# ls
bin  include  lib  share
[root@localhost ffmpeg]#

5.调试程序编译
编译调试(以源码中doc/examples/metadata.c为例):
==>【 pkg-config 是linux下的一个命令,能够方便编译,例如如下编译命令 】

export PKG_CONFIG_PATH=/usr/local/dujnLib/ffmpeg/lib/pkgconfig:$PKG_CONFIG_PATH
gcc metadata.c -o getMetadata `pkg-config  --libs --cflags libavformat`

6.结果:
说明–>PKG_CONFIG_PATH指定pkg-config将要读取的配置文件,这里在
/usr/local/dujnLib/ffmpeg/lib/pkgconfig目录,即目标编译lib目录下的pkgconfig中,自行配置即可。

[root@localhost ffmpeg]# ls
bin  compile.sh  doc  include  lib  metadata.c  README.txt  share  tree.mp4
[root@localhost ffmpeg]# cat compile.sh
#!/bin/sh
export PKG_CONFIG_PATH=/usr/local/dujnLib/ffmpeg/lib/pkgconfig:$PKG_CONFIG_PATH
gcc metadata.c -o getMetadata `pkg-config  --libs --cflags libavformat`
[root@localhost ffmpeg]# ./compile.sh
[root@localhost ffmpeg]# ./getMetadata tree.mp4
major_brand=isom
minor_version=512
compatible_brands=isomiso2avc1mp41
encoder=Lavf55.33.100
[root@localhost ffmpeg]#

::>【 pkg-config 工作本质是对编译项的封装 】

[root@localhost ffmpeg]# pkg-config  --libs --cflags libavformat
-I/usr/local/dujnLib/ffmpeg/include  -pthread -L/usr/local/dujnLib/ffmpeg/lib -lavformat -lavcodec -lz -lswresample -lavutil -lm
[root@localhost ffmpeg]#

==> 【 根据官网有如下库可供选择 】
( libavutil、libavcodec、libavformat、libavdevice、libavfilter、libswscale、libswresample )

libavutil is a library containing functions for simplifying programming, including random number generators, data structures, mathematics routines, core multimedia utilities, and much more.

libavcodec is a library containing decoders and encoders for audio/video codecs.

libavformat is a library containing demuxers and muxers for multimedia container formats.

libavdevice is a library containing input and output devices for grabbing from and rendering to many common multimedia input/output software frameworks, including Video4Linux, Video4Linux2, VfW, and ALSA.

libavfilter is a library containing media filters.

libswscale is a library performing highly optimized image scaling and color space/pixel format conversion operations.

libswresample is a library performing highly optimized audio resampling, rematrixing and sample format conversion operations.

学习文档:https://zhuanlan.zhihu.com/p/41070610

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值