1. 程式人生 > >CentOS7下編譯安裝ffmpeg3.1.5

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就安裝完成了。