Cent OS安装使用ffmpeg
centos作为主流后台linux 系统,ffmpeg作为视频流解析的主力,尤其是ffmpeg配合opencv使用,则是视觉操作的基础
版本:
ffmpeg3.1 + opencv 2.4.13.6
1.ffmpeg安装准备
1)安装必要的扩展
yum install automake autoconf make gcc gcc-c++ libtool zlib zlib-devel curl curl-devel alsa-lib alsa-lib-devel gettext gettext-devel expat expat-devel nasm pkgconfig
2)安装yasm - 支持编译x264
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gztar -zxvf yasm-1.3.0.tar.gzcd yasm-1.3.0./configuremake -j8make install
3)安装gnutls、lame
yum install gnutls gnutls-devel
yum install lame lame-devel
4)安装 x264库
卸载系统自带的旧版x264
yum remove x264 x264-devel
安装 x264
wget -c ftp://ftp.videolan.org/pub/x264/snapshots/x264-snapshot-20120718-2245-stable.tar.bz2# 未安装 bzip2 则执行安装命令yum install bzip2tar jxvf x264-snapshot-20120718-2245-stable.tar.bz2cd x264-snapshot-20120718-2245-stable./configure --enable-shared --enable-staticmake -j8make install
2.安装ffmpeg
wget http://www.ffmpeg.org/releases/ffmpeg-3.1.tar.gztar -zxvf ffmpeg-3.1.tar.gzcd ffmpeg-3.1./configure --prefix=/usr/local/ --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-zlib --enable-bzlib --enable-libmp3lame --enable-libx264 --enable-picmake -j8make install
3.检查ffmpeg 是否安装成功
更新资源
updatedb # yum install mlocate
检查ffmpeg版本
ffmpeg -v
如果提示找不到 libavdevice ... ,在 /etc/ld.so.conf 中配置 /usr/local/lib
vi /etc/ld.so.conf// 新增 : /usr/local/libldconfig
此时检查ffmpeg版本则返回:
ffmpeg version 3.1 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36) configuration: --prefix=/usr/local/ --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-zlib --enable-bzlib --enable-libmp3lame --enable-libx264 --enable-pic libavutil 55. 27.100 / 55. 27.100 libavcodec 57. 48.101 / 57. 48.101 libavformat 57. 40.101 / 57. 40.101 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.102 / 6. 46.102 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 libpostproc 54. 0.100 / 54. 0.100
4.opencv准备
Java的安装 - 略
ant的安装
yum install ant
5.opencv 安装
wget https://github.com/opencv/opencv/archive/2.4.13.6.zipunzip opencv-2.4.13.6.zip # yum install zip unzipcd opencv-2.4.13.6mkdir build && cd build
检查opencv安装依赖
cmake ..
如果没有ffmpeg :
这里,参见 https://stackoverflow.com/questions/5492919/cmake-cant-find-ffmpeg-in-custom-install-path ,需配置 PKG_CONFIG_PATH 变量,而centos默认没有locate,故有以下处理:
yum install mlocate // centos 下安装locatelocate pkgconfigexport PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
再去执行cmake即发现ffmpeg已就绪。
执行编译、安装
make -j8make install
6.opencv检查
检查很简单,build/lib 目录下是否包含:
libopencv_java2413.so
需要用到 opencv - jar 的, build/bin 目录下查看是否包含:
opencv-2413.jar
实际使用中,将 jar包导入项目,或者maven 本地仓库即可。