CentOS7下编译安装ffmpeg3.1.5

一、安装依赖包

# yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64


二、编译依赖包

zlib-1.2.8.tar.gz

# tar-xzvf zlib-1.2.8.tar.gz

# cd zlib-1.2.8

# ./configure

# make

#make install

# cd ..


pcre-8.12.tar.gz 

# tar -xzvf pcre-8.12.tar.gz 

# cd pcre-8.12

# ./configure

# make

#make install

# cd ..


yamdi-1.4.tar.gz

# tar -xzvf yamdi-1.4.tar.gz

# cd yamdi-1.4

# make

#make install

#cd ..


yasm-1.3.0.tar.gz

# tar -xzvf yasm-1.3.0.tar.gz

# cd yasm-1.3.0

# ./configure

# make

#make install

#cd ..


faac-1.28.tar.gz

# tar -xzvf faac-1.28.tar.gz

# cd faac-1.28

#make

#make install

在make是出现错误mpeg4ip.h:126:58: 错误:对‘char* strcasestr(const char*, const char*)’的新声明
 char *strcasestr(const char *haystack, const char *needle);
                                                          ^
In file included from mpeg4ip.h:107:0,
                 from mp4common.h:29,
                 from 3gp.cpp:28:
/usr/include/string.h:365:26: 错误:使旧的声明‘const char* strcasestr(const char*, const char*)’出现歧义
 extern "C++" const char *strcasestr (const char *__haystack,

make[3]: *** [3gp.o] 错误 1
make[3]: 离开目录“/usr/local/src/myffmpeg/faac-1.28/common/mp4v2”
make[2]: *** [all-recursive] 错误 1
make[2]: 离开目录“/usr/local/src/myffmpeg/faac-1.28/common”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/myffmpeg/faac-1.28”
make: *** [all] 错误 2

解决方式为:

修改faac-1.28/common/mp4v2下的文件mpeg4ip.h

从123行开始修改到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


faad2-2.7.tar.gz

# tar -xzvf faad2-2.7.tar.gz

#cd faad2-2.7

# make

#make install

#cd ..


lame-3.99.5.tar.gz

# tar -xzvf lame-3.99.5.tar.gz

# cd lame-3.99.5

#./configure --enable-nasm
# make
# make install
# cd ..


libogg-1.3.2.tar.gz

# tar -xzvf libogg-1.3.2.tar.gz

# cd libogg-1.3.2

# ./configure
# make
# make install
# cd ..


libvorbis-1.3.5.tar.gz

# tar -xzvf libvorbis-1.3.5.tar.gz

# cd libvorbis-1.3.5

# ./configure
# make
# make install
# cd ..


libvpx-1.5.0.tar

# tar -xf libvpx-1.5.0.tar

# cd libvpx-1.5.0

# ./configure  --enable-shared
# make
# make install
# cd ..


SDL-1.2.15.tar.gz

# tar -xzvf SDL-1.2.15.tar.gz

# cd SDL-1.2.15

# make

# make install

# cd ..

在make是出现错误:

./src/video/x11/SDL_x11sym.h:168:17: 错误:与‘_XData32’类型冲突
 SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
                 ^
./src/video/x11/SDL_x11dyn.c:95:5: 附注:in definition of macro ‘SDL_X11_SYM’
  rc fn params { ret p##fn args ; }
     ^
In file included from ./src/video/x11/SDL_x11dyn.h:34:0,
                 from ./src/video/x11/SDL_x11dyn.c:26:
/usr/include/X11/Xlibint.h:681:12: 附注:‘_XData32’的上一个声明在此
 extern int _XData32(
            ^
make: *** [build/SDL_x11dyn.lo] 错误 1

解决方法为:

修改文件./src/video/x11/SDL_x11sym.h

将168行

SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)



修改为

SDL_X11_SYM(int,_XData32,(Display *dpy,register _Xconst long *data,unsigned len),(dpy,data,len),return)


 x264

# cd x264/

# ./configure --enable-shared 
# make
# make install
# cd ..


xvidcore-1.3.4.tar.gz

# tar -xzvf xvidcore-1.3.4.tar.gz

# cd xvidcore/build/generic
# ./configure
# make
# make install
# cd ../..

# cd ..


三、安装ffmpeg3.1.5

ffmpeg-3.1.5.tar

# tar -xf ffmpeg-3.1.5.tar

# cd ffmpeg-3.1.5

# ./configure  --prefix=/usr/local/ffmpeg/ --enable-version3 --enable-libvpx --enable-libfaac --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libxvid --enable-shared --enable-gpl --enable-postproc --enable-nonfree --enable-avfilter --enable-pthreads

# make

# make install

# cd ..


修改/etc/ld.so.conf如下:
include ld.so.conf.d/*.conf
/lib
/lib64
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/usr/local/ffmpeg/lib
# ldconfig


将/usr/local/ffmpeg/bin/ 下的可执行文件复制粘贴在/usr/local/bin/ 下就可以使用了,ffmpeg就安装完成了。


你可能感兴趣的:(Linux相关)