Centos-安装 FFMpeg

CentOS 系统安装 FFMpeg。

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
yum install gcc-c++              # g++编译
yum install gtk2-devel
yum install gimp-devel
yum install gimp-devel-tools
yum install gimp-help-browser
yum install zlib-devel
yum install libtiff-devel # tiff格式图片支持
yum install libjpeg-devel # jpeg图片支持
yum install libpng-devel # png图片支持
yum install gstreamer-devel # 处理MP3、Ogg、MPEG1、MPEG2、AVI等格式的多媒体数据
yum install libavc1394-devel # 1394音频接口的控制命令集
yum install libraw1394-devel
yum install libdc1394-devel
yum install jasper-devel
yum install jasper-utils
yum install cmake # 方便编译构建OpenCV的工具
yum install swig
yum install libtool
yum install nasm # 汇编工具

一行安装:
sudo yum install -y gcc-c++ gtk2-devel gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils cmake swig libtool nasm

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 --enable-nonfree --enable-pic --enable-shared
make -j8
make install

wget http://www.ffmpeg.org/releases/ffmpeg-3.1.tar.gz
tar -zxvf ffmpeg-3.1.tar.gz
cd ffmpeg-3.1
./configure --prefix=/usr/local/ffmpeg/ --enable-shared
make -j8
make install
cp /usr/local/ffmpeg/bin/ffmpeg /usr/bin/

环境变量

编辑 /etc/profile 文件,添加:

1
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/ffmpeg/lib/"

然后执行:

1
source /etc/profile

报错处理

问题:

1
ibavcodec/mqc.o: relocation r_x86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fpic

处理:

1
2
3
config.mak L75加入 -fPIC,然后重新编译
#直接替换,顺序可能不一样
HOSTCFLAGS=-O3 -g -std=c99 -Wall -fPIC

Ubuntu 安装

1
2
3
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next 
sudo apt-get update
sudo apt-get install ffmpeg