微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CentOS下ffmpeg与第三方编码编译安装

一、安装环境

文档日期:2015年7月8日,所下载软件的版本是该日期所在的最新版本。

1、系统

CENTOS7

2、安装依赖包

yum -y install gccglibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-develgettext-devel libtool mhash* perl-Digest-SHA1*

yum -y install makeautomake bzip2 unzip patch subversion libjpeg-devel

3、安装git工具:

(1)yum安装

yum-yinstall git*

(2)源码安装如下

官网:http://git-scm.com/download/

下载地址:http://codemonkey.org.uk/projects/git-snapshots/git/

最新版本:http://codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.xz

cd/home/mycentos7/tools/ffmpeg

wgethttp://codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.xz

tar xJvfgit-latest.tar.xz

cd git-2015-07-08

autoconf

./configure

make

sudo make install

git --version

cd ..

4、安装Yasm工具:

下载地址:http://www.tortall.net/projects/yasm/releases/

最新版本:http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

cd/home/mycentos7/tools/ffmpeg

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

tar xzvf yasm-1.3.0.tar.gz

cd yasm-1.3.0

./configure

make

sudo make install (或使用root安装: make install)

cd ..

二、安装编解码器

1、安装x.264:

官网:http://www.videolan.org/developers/x264.html

下载地址:

最新版本:ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2

(1)git下载

cd/home/mycentos7/tools/ffmpeg

#git clonegit://git.videolan.org/x264

#cd x264

(2)wget下载

cd/home/mycentos7/tools/ffmpeg

wgetftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2

tar xvjflast_stable_x264.tar.bz2

cd x264-snapshot-20150707-2245-stable

(3)编译

./configure–enable-shared –enable-pic --enable-static

make

sudo make install (或使用root安装: make install)

cd ..

2、安装一些格式转换常用的编码库:

yum installfaac-devel lame-devel amrnb-developencore-amr-devel amrwb-devellibvorbis-devel libtheora-devel xvidcore-devel

3、安装LAME:

cd/home/mycentos7/tools/ffmpeg

wgethttp://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz

tar xzvflame-3.99.5.tar.gz

cd lame-3.99.5

./configure--enable-nasm

make

sudo make install (或使用root安装: make install)

cd ..

4、安装libogg:

官网:

下载地址:http://downloads.xiph.org/releases/ogg/

最新版本:http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz

cd/home/mycentos7/tools/ffmpeg

wgethttp://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz

tar xzvf libogg-1.3.2.tar.gz

cd libogg-1.3.2

./configure

make

sudo make install (或使用root安装: make install)

cd ..

5、安装libvorbis:

官网:http://www.vorbis.com/

下载地址:http://downloads.xiph.org/releases/vorbis/

http://www.xiph.org/downloads/

最新版本:http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz

cd/home/mycentos7/tools/ffmpeg

wgethttp://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz

tar xzvf libvorbis-1.3.5.tar.gz

cd libvorbis-1.3.5

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

6、安装libvpx:

cd/home/mycentos7/tools/ffmpeg

git clonehttps://github.com/webmproject/libvpx

cd libvpx

./configure --enable-shared

make

sudo makeinstall (或使用root安装: make install)

cd ..

7、安装FAAD2:

官网:http://www.audiocoding.com/

cd/home/mycentos7/tools/ffmpeg

wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz

tar zxvf faad2-2.7.tar.gz

cd faad2-2.7

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

8、安装FAAC:

官网:http://www.audiocoding.com/

cd/home/mycentos7/tools/ffmpeg

wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz

tar zxvf faac-1.28.tar.gz

cd faac-1.28

直接编译会报错,处理方式有以下三种,任意一种都可以:

(1)sed-i 's@^char \*strcasestr@//char *strcasestr@' ./common/mp4v2/mpeg4ip.h

(2) sed -i '124 s@extern "C"@extern"C++"@' ./common/mp4v2/mpeg4ip.h

sed -i '126 s@^char \*strcasestr@const char *strcasestr@'./common/mp4v2/mpeg4ip.h

(3)参见附录二的处理

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

9、安装Xvid:

官网:https://www.xvid.com/

下载地址:https://www.xvid.com/download/

最新版本:http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz

cd/home/mycentos7/tools/ffmpeg

wget http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz

tar zxvf xvidcore-1.3.4.tar.gz

cdxvidcore/build/generic

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

10、安装frei0r:

官网:http://frei0r.dyne.org/

下载地址:https://www.dyne.org/software/frei0r/

最新版本:https://files.dyne.org/frei0r/snapshots/frei0r-snapshot-27-01-15.tar.gz

(1)源代码下载

cd/home/mycentos7/tools/ffmpeg/

git clonegit://code.dyne.org/frei0r.git

cd frei0r

(2)压缩包下载

下载frei0r-1.4.0.tar.gz

tar zxvf frei0r-1.4.0.tar.gz

cd frei0r-1.4.0

(3)编译

autogen.sh

./configure --enable-shared

make

sudo makeinstall (或使用root安装: make install)

cd ..

(4)编译ffmpeg时的编译选项

--enable-frei0r

(5)ffmpeg frei0r filter 参数及效果

ffmpeg中frei0r滤镜基本使用方法

ffplay -vffrei0r=filter_name=filter_params:filter_params:...

在Windows系统ffmpeg使用frei0r时需要加环境变量 FREI0R_PATH=frei0r安装目录

单击图片复制滤镜命令

ffmpeg使用frei0r参考http://ffmpeg.org/ffmpeg-filters.html#frei0r-1

frei0r的详细参数说明参考http://www.mltframework.org/bin/view/MLT/PluginsFilters

11、安装amr:

(1)编译安装

cd/home/mycentos7/tools/ffmpeg/

wgethttp://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz

tar zxvfopencore-amr-0.1.3.tar.gz

cd opencore-amr-0.1.3

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

编译ffmpeg时的编译选项

--enable-libopencore-amrnb

(2)使用

使用方法

ffmpeg -i 1.mp3 -ac1 -ar 8000 1.amr #MP3转换AMR

ffmpeg -i 1.amr1.mp3 #AMR转换MP3

A. 转换amr到mp3:

ffmpeg -ishenhuxi.amr amr2mp3.mp3

B. 转换amr到wav:

ffmpeg -acodeclibamr_nb -i shenhuxi.amr amr2wav.wav

C. 转换mp3到wav:

ffmpeg -i DING.mp3-f wav test.wav

D. 转换wav到amr:

ffmpeg -i test.wav-acodec libamr_nb -ab 12.2k -ar 8000 -ac 1 wav2amr.amr

E. 转换wav到mp3:

ffmpeg -i test.wav-f mp3 -acodec libmp3lame -y wav2mp3.mp3

12、安装amrnb:

(1)源代码下载

cd /home/mycentos7/tools/ffmpeg/

wgethttp://www.penguin.cz/~utx/ftp/amr/amrnb-11.0.0.0.tar.bz2

tar xjvf amrnb-11.0.0.0.tar.bz2

(2)压缩包下载

下载amrnb-11.0.0.0.tar.gz

tar zxvf amrnb-11.0.0.0.tar.gz

(3)编译

cd amrnb-11.0.0.0

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

13、安装amrwb:

(1)源代码下载

cd/home/mycentos7/tools/ffmpeg/

wgethttp://www.penguin.cz/~utx/ftp/amr/amrwb-11.0.0.0.tar.bz2

tar xjvfamrwb-11.0.0.0.tar.bz2

(2)压缩包下载

下载amrwb-11.0.0.0.tar.gz

tar zxvfamrwb-11.0.0.0.tar.gz

(3)编译

cd amrwb-11.0.0.0

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

14、安装OpenCV:

(0)系统安装

yum install opencv

(1)介绍

OpenCV是Intel公司开发的图像处理和计算机视觉函数

其中OpenCV最新的源代码

http://opencvlibrary.svn.sourceforge.net/viewvc/opencvlibrary/trunk/opencv/src/

代码及文档下载:SOURCEFORGE.NET:

http://sourceforge.net/projects/opencvlibrary/

INTEL的OPENCV主页:http://www.intel.com/research/mrl/research/opencv/

(2)预安装依赖组件

yum install bzip2-develcmake* gcc gcc-c++ gimp-devel gimp-devel-tools gimp-help-browser gtk+-devel gtk*gstreamer-devel libtiff-devel libjpeg-devel libpng-devel libavc1394-devellibraw1394-devel libdc1394-devel jasper-devel jasper-utils swig python libtoolnasm ncurses-devel openssl-devel sqlite-devel zlib-devel

(3)源代码下载

cd/home/mycentos7/tools/ffmpeg/

wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/3.0.0/opencv-3.0.0.zip

unzip -d . opencv-3.0.0.zip

(4)压缩包下载

cd/home/mycentos7/tools/ffmpeg/

下载opencv-3.0.0.tar.gz

tar zxvf opencv-3.0.0.tar.gz

(5)编译安装

cd opencv-3.0.0

mkdir build; cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -DBUILD_DOCS=ON -D BUILD_EXAMPLES=ON -D BUILD_TESTS=ON -D INSTALL_C_EXAMPLES=ON-D INSTALL_TESTS=ON -DWITH_FFMPEG=OFF-D WITH_GSTREAMER=ON -DWITH_JPEG=ON -D WITH_PNG=ON -DWITH_GTK=OFF-D WITH_V4L=ON ../

make

sudo makeinstall (或使用root安装: make install)

cd ..

(6)开发环境配置(A或B)

A、创建连接

ln -s /usr/local/lib/pkgconfig/opencv.pc /usr/lib64/pkgconfig/opencv.pc

B、设置环境变量

exportPKG_CONfig_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig: PKG_CONfig_PATH

C、不做上面的错误,在编译ffmpeg使用opencv是会报如下错误

Packageopencv was not found in the pkg-config search path.

Perhapsyou should add the directory containing `opencv.pc'

tothe PKG_CONfig_PATH environment variable

nopackage 'opencv' found

ERROR:libopencv not found

(7)另外一种安装方法

cd/home/mycentos7/tools/ffmpeg/

wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/3.0.0/opencv-3.0.0.zip

unzip -d . opencv-3.0.0.zip

cd opencv-3.0.0

mkdir build; cd build; ccmake ../

A、执行完上述命令后,会出现ccmake的界面,然后在键盘上按下c键,然后ccmake就会去查看你的编译环境的。

B、等cmake检查完后,根据出现的内容,选择合适的选项,比如如果你没有cuda或者opencl的话,可以将与这些信息有关的项都设置成off。

C、建议以下项保持为ON

BUILD_DOCS

BUILD_EXAMPLES

INSTALL_C_EXAMPLES

WITH_FFMPEG

WITH_GSTREAMER

WITH_JPEG

WITH_GTK

WITH_PNG

WITH_V4L

D、设置完成后,再次敲击键盘上的c键,待配置完成。(4) 配置检测完成后,敲击键盘上的g键,待cmake退出后。

E、执行下面的命令以完成编译:

make

这个编译过程可能需要一段时间,耐心等待一会,你可以用这段时间看看书,喝点水。

F、待编译完成后,最后一个命令:

sudo makeinstall (或使用root安装: make install)

cd ..

(8)编译遇到的问题

A、编译swscale是没有使用fPIC显示如下错误

/bin/ld:/usr/local/include/../lib/libswscale.a(swscale.o): relocation R_X86_64_PC32against symbol `ff_M24A' can notbe used when making a shared object;recompile with-fPIC

解决方法:编译ffmpeg是使用PIC选项

CFLAGS="-O3-fPIC" ./configure --enable-gpl --enable-version3 --enable-shared--enable-nonfree --enable-postproc --enable-x11grab --enable-gray--enable-small --enable-bzlib --enable-frei0r --enable-libopencore-amrnb--enable-libopencore-amrwb

make

make install

B、如果已经安装ffmpeg,将会报如下错误:出现avformat_free_context和AVCodecID未声明:

cap_ffmpeg.cpp:45:0:

cap_ffmpeg_impl.hpp:在成员函数‘voidCvVideoWriter_FFMPEG::close()’中:

cap_ffmpeg_impl.hpp:1532:29:错误:‘avformat_free_context’在此作用域中尚未声明

avformat_free_context(oc);

^

cap_ffmpeg.cpp:45:0:

cap_ffmpeg_impl.hpp:在全局域:

cap_ffmpeg_impl.hpp:1546:71:错误:使用枚举‘AVCodecID’前没有给出声明

static inline bool cv_ff_codec_tag_match(constAVCodecTag *tags,enum AVCodecID id,unsigned int tag)

^

cap_ffmpeg_impl.hpp:1556:83:错误:使用枚举‘AVCodecID’前没有给出声明

static inline boolcv_ff_codec_tag_list_match(const AVCodecTag *const *tags,unsigned int tag)

解决方法:将WITH_FFMPEG=OFF

./configure--enable-shared

C、如果已经安装GTK,将会报如下错误:出现未定义的引用:

Linking CXXexecutable ../../bin/opencv_test_core

/lib64/libgtk-3.so.0:对‘g_type_add_instance_private’未定义的引用

/lib64/libgtk-3.so.0:对‘g_type_class_adjust_private_offset’未定义的引用

/lib64/libgtk-3.so.0:对‘g_variant_parse_error_quark’未定义的引用

collect2: 错误:ld 返回 1

make[2]: ***[bin/opencv_test_core] 错误1

make[1]: ***[modules/core/CMakeFiles/opencv_test_core.dir/all] 错误 2

make: *** [all] 错误 2

解决方法:将WITH_GTK=OFF

15、安装libdc1394:

yum installlibdc1394

16、安装ORC(libdirac依赖于该包):

官网:http://code.entropywave.com/projects/orc/

(1)安装方法

cd/home/mycentos7/tools/ffmpeg/

wget http://code.entropywave.com/download/orc/orc-0.4.18.tar.gz

tar zxvf orc-0.4.18.tar.gz

cd orc-0.4.18

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

(2)设置

ln -s /usr/local/lib/pkgconfig/orc-0.4.pc /usr/lib64/pkgconfig/orc-0.4.pc

否则在dirac编译时报错误:

checking for ORC...no

configure: error:orc-0.4 >= 0.4.16 is required

17、安装dirac编码:

yum install dirac*

官网:http://diracvideo.org/

cd/home/mycentos7/tools/ffmpeg/

wget http://diracvideo.org/download/schroedinger/schroedinger-1.0.11.tar.gz

tar zvxfschroedinger-1.0.11.tar.gz

cd schroedinger-1.0.11

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

ln -s /usr/local/lib/pkgconfig/schroedinger-1.0.pc /usr/lib64/pkgconfig/schroedinger-1.0.pc

18、安装libdirac:

官网:http://sourceforge.net/projects/dirac

yum install scons

ln -s /usr/local/lib/pkgconfig/libavcodec.pc /usr/lib64/pkgconfig/libavcodec.pc

cd/home/mycentos7/tools/ffmpeg/

wget http://downloads.sourceforge.net/project/dirac/dirac-codec/Dirac-1.0.2/dirac-1.0.2.tar.gz

tar zvxf dirac-1.0.2.tar.gz

cd dirac-1.0.2

./configure

sed -i '127 s@unsigned charnext_parse_code;@//unsigned char next_parse_code;@'./libdirac_byteio/parseunit_byteio.cpp

sed -i '129 s@next_parse_code =InputUnByte();@InputUnByte();@' ./libdirac_byteio/parseunit_byteio.cpp

sed -i '131 s@intnext_unit_next_parse_offset;@//int next_unit_next_parse_offset;@'./libdirac_byteio/parseunit_byteio.cpp

sed -i '132 s@next_unit_next_parse_offset= ReadUintLit(PU_NEXT_PARSE_OFFSET_SIZE);@ReadUintLit(PU_NEXT_PARSE_OFFSET_SIZE);@'./libdirac_byteio/parseunit_byteio.cpp

sed -i '162,337,503 s@intstep,max; @int step,max; max=max;@' ./libdirac_common/mv_codec.cpp

make

sudo make install (或使用root安装: make install)

cd ..

如果不使用sed修改代码,将出现如下错误:

parseunit_byteio.cpp:在成员函数‘booldirac::ParseUnitByteIO::IsValid()’中:

parseunit_byteio.cpp:127:23:错误:variable ‘next_parse_code’ set but not used[-Werror=unused-but-set-variable]

unsigned char next_parse_code;

^

parseunit_byteio.cpp:131:13:错误:variable ‘next_unit_next_parse_offset’ set but notused [-Werror=unused-but-set-variable]

int next_unit_next_parse_offset;

^

cc1plus: somewarnings being treated as errors

make[1]: ***[libdirac_byteio_la-parseunit_byteio.lo] 错误

如果不使用sed修改代码,将出现如下错误:

_comp.o

mot_comp.cpp: 在成员函数‘virtual voiddirac::MotionCompensator_EighthPixel::BlockPixelPred(dirac::TwoDArray<shortint>&,const ImageCoords&,constdirac::PicArray&,const MVector&)’中:

mot_comp.cpp:1119:53:错误:narrowing conversion of‘((4 - ((int)rmdr.dirac::MotionVector<int>::x)) *(4 - ((int)rmdr.dirac::MotionVector<int>::y)))’from ‘int’ to ‘const ValueType {aka const short int}’inside { } is ill-formed in C++11 [-Werror=narrowing]

const ValueType linear_wts[4] = { (4 - rmdr.x) * (4 - rmdr.y),//tl

^

mot_comp.cpp:1120:44:错误:narrowing conversion of‘(((int)rmdr.dirac::MotionVector<int>::x) * (4 -((int)rmdr.dirac::MotionVector<int>::y)))’ from ‘int’ to ‘constValueType {aka const short int}’ inside { } isill-formed in C++11 [-Werror=narrowing]

rmdr.x *(4 - rmdr.y),//tr

^

mot_comp.cpp:1121:50:错误:narrowing conversion of‘((4 - ((int)rmdr.dirac::MotionVector<int>::x)) *((int)rmdr.dirac::MotionVector<int>::y))’ from ‘int’ to ‘constValueType {aka const short int}’ inside { } isill-formed in C++11 [-Werror=narrowing]

(4 - rmdr.x) *rmdr.y,//bl

^

mot_comp.cpp:1122:44:错误:narrowing conversion of‘(((int)rmdr.dirac::MotionVector<int>::x) *((int)rmdr.dirac::MotionVector<int>::y))’ from ‘int’ to ‘constValueType {aka const short int}’ inside { } isill-formed in C++11 [-Werror=narrowing]

rmdr.x *rmdr.y }; //br

^

cc1plus: allwarnings being treated as errors

make[1]: ***[libdirac_common_la-mot_comp.lo] 错误 1

19、安装bzip2:

官网:http://bzip.org/downloads.html

下载地址:http://bzip.org/downloads.html

cd/home/mycentos7/tools/ffmpeg/

wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz

tar zxvf bzip2-1.0.6.tar.gz

cd bzip2-1.0.6

sed -i '24 s@-Wall@-Wall-fPIC@' ./Makefile

make

sudo makeinstall (或使用root安装: make install)

cd ..

20、安装zlib:

官网:http://zlib.net/

下载地址:http://zlib.net/zlib-1.2.8.tar.gz

最新版本:http://zlib.net/zlib-1.2.8.tar.gz

cd/home/mycentos7/tools/ffmpeg/

wget http://zlib.net/zlib-1.2.8.tar.gz

tar zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

21、安装xavs:

最新版本:

http://sourceforge.net/code-snapshots/svn/x/xa/xavs/code/xavs-code-55-trunk.zip

cd/home/mycentos7/tools/ffmpeg/

wget wgethttp://sourceforge.net/code-snapshots/svn/x/xa/xavs/code/xavs-code-55-trunk.zip

unzip xavs-code-55-trunk.zip

cd xavs-code-55-trunk

./configure

./configure --extra-cflags=-fPIC

make

sudo makeinstall (或使用root安装: make install)

cd ..

22、安装libspeex:

官网:http://www.speex.org

下载地址:

最新版本:http://downloads.xiph.org/releases/speex/speex-1.2rc2.tar.gz

cd/home/mycentos7/tools/ffmpeg/

wget http://downloads.xiph.org/releases/speex/speex-1.2rc2.tar.gz

tar zxvf speex-1.2rc2.tar.gz

cd speex-1.2rc2

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

ln -s /usr/local/lib/pkgconfig/speex.pc /usr/lib64/pkgconfig/speex.pc

23、安装librtmp:

官网:http://rtmpdump.mplayerhq.hu

cd/home/mycentos7/tools/ffmpeg/

git clonegit://git.ffmpeg.org/rtmpdump

mv rtmpdump rtmpdump-2.4

cd rtmpdump-2.4

make

sudo makeinstall (或使用root安装: make install)

cd ..

ln -s /usr/local/lib/pkgconfig/librtmp.pc /usr/lib64/pkgconfig/librtmp.pc

24、安装libopenjpeg:

官网:http://www.openjpeg.org/

下载地址:https://github.com/uclouvain/openjpeg/releases/latest

最新版本:https://github.com/uclouvain/openjpeg/archive/version.2.1.tar.gz

使用1.5.3版本

cd/home/mycentos7/tools/ffmpeg/

wgethttps://github.com/uclouvain/openjpeg/archive/version.1.5.2.zip

mv version.1.5.2.zipopenjpeg-version.1.5.2.zip

unzip openjpeg-version.1.5.2.zip

cd openjpeg-version.1.5.2

cmake .

make

sudo makeinstall (或使用root安装: make install)

cd ..

ln -s /usr/local/lib/pkgconfig/libopenjpeg1.pc/usr/lib64/pkgconfig/libopenjpeg1.pc

cp /usr/local/include/openjpeg-1.5/openjpeg.h/usr/local/include/

25、安装libnut:

cd/home/mycentos7/tools/ffmpeg/

svn checkoutsvn://svn.mplayerhq.hu/nut/src/trunk libnut

cd libnut

sed -i '6s@-Wall@-Wall -fPIC@' ./config.mak

make

sudo makeinstall (或使用root安装: make install)

cd ..

26、安装libgsm:

yum install gsm*

下面的安装有问题,仅供参考

官网:http://libgsm.sourcearchive.com/

下载地址:http://libgsm.sourcearchive.com/downloads/1.0.13-4/

最新版本:

http://libgsm.sourcearchive.com/downloads/1.0.13-4/libgsm_1.0.13.orig.tar.gz

cd /home/mycentos7/tools/ffmpeg/

wget http://libgsm.sourcearchive.com/downloads/1.0.13-4/libgsm_1.0.13.orig.tar.gz

tar zxvf libgsm_1.0.13.orig.tar.gz

cd gsm-1.0-pl13

./configure

make

sudo makeinstall (或使用root安装: make install)

cd ..

cp inc/gsm.h /usr/local/include/

cp lib/libgsm.a /usr/local/lib/

三、ffmpeg下载安装

1、让动态链接库被系统共享:

修改/etc/ld.so.conf如下:

includeld.so.conf.d/*.conf

/lib

/lib64

/usr/lib

/usr/lib64

/usr/local/lib

/usr/local/lib64

/opt/ffmpeg/lib

保存后执行

ldconfig

2、下载FFmpeg:

官网:http://ffmpeg.org

下载地址:http://ffmpeg.org/download.html

最新版本:http://ffmpeg.org/releases/ffmpeg-2.7.1.tar.bz2

cd/home/mycentos7/tools/ffmpeg

(1)git下载

git clonegit://source.ffmpeg.org/ffmpeg

(2)wget下载

wgethttp://ffmpeg.org/releases/ffmpeg-2.7.1.tar.bz2

(3)svn下载

svn checkoutsvn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

3、编译:

tar jxvf ffmpeg-2.7.1.tar.bz2

cd ffmpeg-2.7.1

sed -i '29s@#include@//#include@' ./libavfilter/vf_libopencv.c

./configure--enable-gpl --enable-version3 --enable-shared --enable-nonfree--enable-postproc --enable-x11grab --enable-gray --enable-small --enable-bzlib--enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb--enable-libopencv --enable-libdc1394 --enable-zlib --enable-libxvid--enable-libxavs --enable-libx264 --enable-libvpx --enable-libvorbis--enable-libtheora --enable-libspeex --enable-libschroedinger --enable-librtmp--enable-libopenjpeg --enable-libnut --enable-libmp3lame --enable-libgsm--enable-libfaac --enable-libdirac --enable-libdc1394 --enable-libopencv--enable-libopencore-amrwb --enable-libopencore-amrnb --enable-frei0r--enable-bzlib

make

sudo makeinstall (或使用root安装: make install)

cd ..

4、帮助:

./configure --help

Usage: configure[options]

Options: [defaultsin brackets after descriptions]

Standard options:

--help print this message

--logfile=FILE log tests and output to FILE[config.log]

--disable-logging do not log configure debug @R_886_4045@ion

--prefix=PREFIX install in PREFIX []

--bindir=DIR install binaries in DIR[PREFIX/bin]

--datadir=DIR install data files in DIR[PREFIX/share/ffmpeg]

--libdir=DIR install libs in DIR [PREFIX/lib]

--shlibdir=DIR install shared libs in DIR[PREFIX/lib]

--incdir=DIR install includes in DIR[PREFIX/include]

--mandir=DIR install man page in DIR[PREFIX/share/man]

Configurationoptions:

--disable-static do not build static libraries [no]

--enable-shared build shared libraries [no]

--enable-gpl allow use of GPL code,theresulting libs

and binaries will beunder GPL [no]

--enable-version3 upgrade (L)GPL to version 3 [no]

--enable-nonfree allow use of nonfree code,theresulting libs

and binaries will beunredistributable [no]

--disable-doc do not build documentation

--disable-ffmpeg disable ffmpeg build

--disable-ffplay disable ffplay build

--disable-ffprobe disable ffprobe build

--disable-ffserver disable ffserver build

--disable-avdevice disable libavdevice build

--disable-avcodec disable libavcodec build

--disable-avcore disable libavcore build

--disable-avformat disable libavformat build

--disable-swscale disable libswscale build

--enable-postproc enable GPLed postprocessing support[no]

--disable-avfilter disable video filter support [no]

--disable-pthreads disable pthreads [auto]

--enable-w32threads use Win32 threads [no]

--enable-x11grab enable X11 grabbing [no]

--disable-network disable network support [no]

--disable-mpegaudio-hp faster (but less accurate) MPEG audiodecoding [no]

--enable-gray enable full grayscale support(slower color)

--disable-swscale-alpha disable alpha channel support in swscale

--disable-fastspan disable table-based spanision

--enable-small optimize for size instead of speed

--disable-aandct disable AAN DCT code

--disable-dct disable DCT code

--disable-fft disable FFT code

--disable-Golomb disable Golomb code

--disable-huffman disable Huffman code

--disable-lpc disable LPC code

--disable-mdct disable MDCT code

--disable-rdft disable RDFT code

--disable-vaapi disable VAAPI code

--disable-vdpau disable VDPAU code

--disable-dxva2 disable DXVA2 code

--enable-runtime-cpudetect detect cpucapabilities at runtime (bigger binary)

--enable-hardcoded-tables use hardcodedtables instead of runtime generation

--enable-memalign-hack emulate memalign,interferes with memorydebuggers

--disable-everything disable all components listed below

--disable-encoder=NAME disable encoder NAME

--enable-encoder=NAME enable encoder NAME

--disable-encoders disable all encoders

--disable-decoder=NAME disable decoder NAME

--enable-decoder=NAME enable decoder NAME

--disable-decoders disable all decoders

--disable-hwaccel=NAME disable hwaccel NAME

--enable-hwaccel=NAME enable hwaccel NAME

--disable-hwaccels disable all hwaccels

--disable-muxer=NAME disable muxer NAME

--enable-muxer=NAME enable muxer NAME

--disable-muxers disable all muxers

--disable-demuxer=NAME disable demuxer NAME

--enable-demuxer=NAME enable demuxer NAME

--disable-demuxers disable all demuxers

--enable-parser=NAME enable parser NAME

--disable-parser=NAME disable parser NAME

--disable-parsers disable all parsers

--enable-bsf=NAME enable bitstream filter NAME

--disable-bsf=NAME disable bitstream filter NAME

--disable-bsfs disable all bitstream filters

--enable-protocol=NAME enable protocol NAME

--disable-protocol=NAME disable protocol NAME

--disable-protocols disable all protocols

--disable-indev=NAME disable input device NAME

--disable-outdev=NAME disable output device NAME

--disable-indevs disable input devices

--disable-outdevs disable output devices

--disable-devices disable all devices

--enable-filter=NAME enable filter NAME

--disable-filter=NAME disable filter NAME

--disable-filters disable all filters

--list-decoders show all available decoders

--list-encoders show all available encoders

--list-hwaccels show all available hardwareaccelerators

--list-muxers show all available muxers

--list-demuxers show all available demuxers

--list-parsers show all available parsers

--list-protocols show all available protocols

--list-bsfs show all available bitstreamfilters

--list-indevs show all available input devices

--list-outdevs show all available output devices

--list-filters show all available filters

External librarysupport:

--enable-avisynth enable reading of avisynth script files[no]ERROR: vfw32 not found

--enable-bzlib enable bzlib [autodetect]

--enable-frei0r enable frei0r video filtering

--enable-libopencore-amrnb enable AMR-NBde/encoding via libopencore-amrnb [no]

--enable-libopencore-amrwb enable AMR-WBdecoding via libopencore-amrwb [no]

--enable-libopencv enable video filtering via libopencv[no]

--enable-libdc1394 enable IIDC-1394 grabbing usinglibdc1394

and libraw1394 [no]

--enable-libdirac enable Dirac support via libdirac [no]

--enable-libfaac enable FAAC support via libfaac [no]

--enable-libgsm enable GSM support via libgsm [no]

--enable-libmp3lame enable MP3 encoding via libmp3lame [no]

--enable-libnut enable NUT (de)muxing via libnut,

native (de)muxer exists [no]

--enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG[no]

--enable-librtmp enable RTMP[E] support via librtmp[no]

--enable-libschroedinger enable Dirac supportvia libschroedinger [no]

--enable-libspeex enable Speex decoding via libspeex [no]

--enable-libtheora enable Theora encoding via libtheora[no]

--enable-libvorbis enable Vorbis encoding via libvorbis,

nativeimplementation exists [no]

--enable-libvpx enable VP8 support via libvpx [no]

--enable-libx264 enable H.264 encoding via x264 [no]

--enable-libxavs enable AVS encoding via xavs [no]

--enable-libxvid enable Xvid encoding via xvidcore,

native MPEG-4/Xvidencoder exists [no]

--enable-mlib enableSun medialib [no]

--enable-zlib enable zlib [autodetect]

Advanced options(experts only):

--source-path=PATH path to source code [/home/mycentos7/tools/ffmpeg/ffmpeg]

--cross-prefix=PREFIX use PREFIX for compilation tools []

--enable-cross-compile assume a cross-compiler is used

--sysroot=PATH root of cross-build tree

--sysinclude=PATH location of cross-build system headers

--target-os=OS compiler targets OS []

--target-exec=CMD command to run executables on target

--target-path=DIR path to view of build directory ontarget

--nm=NM use nm tool

--ar=AR use archive tool AR [ar]

--as=AS use assembler AS []

--cc=CC use C compiler CC [gcc]

--ld=LD use linker LD

--host-cc=HOSTCC use host C compiler HOSTCC

--host-cflags=HCFLAGS use HCFLAGS when compiling for host

--host-ldflags=HLDFLAGS use HLDFLAGS when linking for host

--host-libs=HLIBS use libs HLIBS when linking for host

--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS []

--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS[]

--extra-libs=ELIBS add ELIBS []

--extra-version=STRING version string suffix []

--build-suffix=SUFFIX library name suffix []

--arch=ARCH select architecture []

--cpu=cpu select the minimum required cpu(affects

instructionselection,may crash on older cpus)

--disable-asm disable all assembler optimizations

--disable-altivec disable AltiVec optimizations

--disable-amd3dNow disable 3DNow! optimizations

--disable-amd3dNowext disable 3DNow! extended optimizations

--disable-mmx disable MMX optimizations

--disable-mmx2 disable MMX2 optimizations

--disable-sse disable SSE optimizations

--disable-ssse3 disable SSSE3 optimizations

--disable-armv5te disable armv5te optimizations

--disable-armv6 disable armv6 optimizations

--disable-armv6t2 disable armv6t2 optimizations

--disable-armvfp disable ARM VFP optimizations

--disable-iwmmxt disable iwmmxt optimizations

--disable-mmi disable MMI optimizations

--disable-neon disable neon optimizations

--disable-vis disable VISoptimizations

--disable-yasm disable use of yasm assembler

--enable-pic build position-independent code

--malloc-prefix=PFX prefix malloc and related names with PFX

--enable-sram allow use of on-chip SRAM

--disable-symver disable symbol versioning

Developer options(useful when working on FFmpeg itself):

--disable-debug disable debugging symbols

--enable-debug=LEVEL set the debug level []

--disable-optimizations disable compiler optimizations

--enable-extra-warnings enable more compiler warnings

--disable-stripping disable stripping of executables andshared libraries

--samples=PATH location of test samples for FATE

NOTE: Object filesare built at the place where configure is launched.

5、官方ffmpeg第三方编码版本:

git: g379ddc6 built on 20150726

build:ffmpeg-git-32bit-static.tar.xz

build:ffmpeg-git-64bit-static.tar.xz

release: 2.7.2

build:ffmpeg-release-32bit-static.tar.xz

build:ffmpeg-release-64bit-static.tar.xz

gcc: 4.9.3

yasm: 1.3.0

libass: 0.12.3

libvpx: 1.4.0-865-g55c6a74

libx264: 0.146.109 121396c

libx265: 1.7+373-db59e6d9b85b

libxvid: 1.3.4-1

libwebp: 0.4.3

libgnutls: 3.3.15

libtheora: 1.1.1

libvidstab: 1.10

libfreetype: 2.5.2-4

libopenjpeg: 1.5.2

libsoxr: 0.1.1

libopus: 1.1-2

libspeex: 1.2

libvorbis: 1.3.4-2

libmp3lame: 3.99.5

libvo-aacenc: 0.1.3-1

libvo-amrwbenc: 0.1.3-1

libopencore-amrnb: 0.1.3-2.1

libopencore-amrwb: 0.1.3-2.1

6、其他第三方编码:

(1) freetype

官网:http://www.freetype.org

下载:http://sourceforge.net/projects/freetype/files/

(2) libtheora

官网:www.theora.org

下载:http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2

(3) libiconv

官网:http://www.gnu.org/software/libiconv/

下载:http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

(4) fdk-aac

下载:http://downloads.sourceforge.net/project/opencore-amr

(5) vo-aacenc

下载:http://sourceforge.net/projects/opencore-amr/files/vo-aacenc/

(6) vo-amrwbenc

下载:http://sourceforge.net/projects/opencore-amr/files/vo-amrwbenc/

(7) opencore-amr

下载:http://sourceforge.net/projects/opencore-amr/files/opencore-amr/

附录一、参考

1、百度经验:http://jingyan.baidu.com/article/95c9d20daaf946ec4e756191.html

2、http://www.poluoluo.com/server/201405/272967.html

附录二、编译FAAC-1.28时遇到错误

mpeg4ip.h:126:error: new declaration ‘char* strcasestr(const char*,const char*)’

解决方法

从123行开始修改文件mpeg4ip.h,到129行结束。

修改前:

#ifdef __cplusplus

extern "C"{

#endif

char*strcasestr(const char *haystack,const char *needle);

#ifdef __cplusplus

}

#endif

修改后:

#ifdef __cplusplus

extern"C++" {

#endif

const char*strcasestr(const char *haystack,const char *needle);

#ifdef __cplusplus

}

#endif

附录三、运行ffmpeg -formats,可能出的错误

ffmpeg: error whileloading shared libraries: libavfilter.so.0: cannot open shared object file: Nosuch file or directory

这事没有设置环境路径造成了,增加一个ffmpeg.conf配置文件:

# cd/etc/ld.so.conf.d

# vi ffmpeg.conf

文件内写上:

/usr/local/lib

然后确认生效:

# ldconfig

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。