歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 6.2下編譯mpeg4ip

CentOS 6.2下編譯mpeg4ip

日期:2017/2/28 15:46:48   编辑:Linux教程

一、環境

1、操作系統版本

CentOS 6.2 64

uname -a的輸出:

Linux localhost.localdomain 2.6.32-220.17.1.el6.x86_64 #1 SMP Wed May 16 00:01:37 BST 2012 x86_64 x86_64 x86_64 GNU/Linux

2mpeg4ip版本

版本:1.6.1

下載鏈接:

http://people.freebsd.org/~ahze/distfiles/mpeg4ip-1.6.1.tar.gz

二、編譯

1、編譯mpeg4ip需要的庫

首先安裝libtool庫,命令如下:

yum install libtool

然後進入到mpeg4ip的目錄,運行./bootstrap進行配置,如果出錯,是因為bash版本及名稱的問題,修改bootstrap文件中第一行,改sh 為bash.或運行 bash ./bootstrap。

提示如下:

*** ffmpeg encoder is not installed
*** xvid encoder is not installed
*** x264 encoder is not installed
*** lame encoder is not installed
*** faac encoder is not installed
*** twolame encoder is not installed

安裝相應庫:

yum install ffmpeg-devel xvidcore-devel twolame-devel x264-devel

編譯:make

2、編譯中的錯誤處理

2.1 報錯內容:

In file included from config_opts.cpp:1:
/include/mpeg4ip.h:126: error: new declaration 'char* strcasestr(const char*, const char*)'
/usr/include/string.h:369: error: ambiguates old declaration 'const char* strcasestr(const char*, const char*)'

解決辦法:

vi include/mpeg4ip.h

注釋掉函數聲明,如下所示:

2.2 報錯內容:

cc1plus: warnings being treated as errors
sys_decoder_blkdec.cpp:190: error: suggest parentheses around '&&' within '||'
sys_decoder_blkdec.cpp:205: error: suggest parentheses around '&&' within '||'

如圖所示:

解決辦法:

vi common/video/iso-mpeg4/src/Makefile

去掉Werror

vi命令: %s/-Werror//

2.3 報錯內容:

type_basic.cpp:320: error: '<anonymous>' has incomplete type
type_basic.cpp:320: error: invalid use of 'Void'
type_basic.cpp:320: error: prototype for 'Void CMotionVector::setToZero(<type error>)' does not match any in class 'CMotionVector'
./../include/basic.hpp:441: error: candidate is: Void CMotionVector::setToZero()

解決辦法:

vi common/video/iso-mpeg4/src/type_basic.cpp

在320行去掉括號內的Void,如圖所示:

2.4 報錯內容:

cc1: warnings being treated as errors
config.c: In function 'enter_chn':
config.c:636: error: array subscript is above array bounds
config.c:637: error: array subscript is above array bounds

解決辦法:

vi player/lib/audio/faad/Makefile

去掉Werror

2.5 報錯內容:

/usr/local/include/libavutil/common.h: In function ‘int32_t av_clipl_int32(int64_t)’:
/usr/local/include/libavutil/common.h:154: error: ‘UINT64_C’ was not declared in this scope
...

解決辦法:

涉及到標准c和c99的問題,在出問題的文件中加上下面三句話就好了

#ifndef UINT64_C
#define UINT64_C(value)__CONCAT(value,ULL)
#endif

2.6 報錯內容:

In file included from ffmpeg.cpp:26:
ffmpeg.h:29:28: error: ffmpeg/avcodec.h: No such file or directory
...

解決辦法:

版本遺留問題,修改下路徑就行了。其實這是一類問題,接下來還會遇到好多次,以這個為例展例下,其它的照此修改就OK了。

vi player/plugin/audio/ffmpeg/ffmpeg.h

在第30行進行修改,替換成完整路徑:

#include <ffmpeg-spice/libavcodec/avcodec.h>

2.7 報錯內容:

ffmpeg.cpp: In function 'codec_data_t* ffmpeg_create(const char*, const char*, int, int, format_list_t*, audio_info_t*, const uint8_t*, uint32_t, audio_vft_t*, void*)':
ffmpeg.cpp:180: error: 'AVCODEC_MAX_AUDIO_FRAME_SIZE' was not declared in this scope
ffmpeg.cpp: In function 'int ffmpeg_decode(codec_data_t*, frame_timestamp_t*, int, int*, uint8_t*, uint32_t, void*)':

解決辦法:

vi /usr/include/ffmpeg-spice/libavcodec/avcodec.h

查找 AVCODEC_MAX_AUDIO_FRAME_SIZE,得到如下結果:

復制其值到文件player/plugin/audio/ffmpeg/ffmpeg.h,並把Q去掉:

vi player/plugin/audio/ffmpeg/ffmpeg.h

添加如下內容:

#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000

2.8 報錯內容:

media_utils.cpp: In function 'int create_media_for_iptv(CPlayerSession*, const char*, int, control_callback_vft_t*)':
media_utils.cpp:613: error: invalid conversion from 'const char*' to 'char*'

解決辦法:

vi player/src/media_utils.cpp

在613行,對name變量進行強制類型轉換,如圖所示:

2.9 報錯內容:

../server/mp4live/video_util_resize.h:93: error: conflicting declaration 'uint8_t* fV'
../server/mp4live/video_util_resize.h:91: error: 'fV' has a previous declaration as 'const uint8_t* fV'
../server/mp4live/video_util_resize.h:94: error: redefinition of 'uint32_t tvStride'
../server/mp4live/video_util_resize.h:94: error: 'uint32_t tvStride' previously declared here
解決辦法:
這個就是函數聲明的時候變量重名了,把名字修改的不同就OK了。這是我修改:
void CopyYuv(const uint8_t *fY, const uint8_t *fU, const uint8_t *fV,
             uint32_t fyStride, uint32_t fuStride, uint32_t fvStride2,
             uint8_t *tY, uint8_t *tU, uint8_t *fV2,
             uint32_t tyStride, uint32_t tvStride, uint32_t tvStride2,
             uint32_t w, uint32_t h); 
2.10 報錯內容:
video_ffmpeg.cpp:124: error: 'struct AVCodecContext' has no member named 'frame_rate'
video_ffmpeg.cpp:125: error: 'struct AVCodecContext' has no member named 'frame_rate_base'
video_ffmpeg.cpp:136: error: 'struct AVCodecContext' has no member named 'aspect_ratio'
解決辦法:
這幾個錯誤影響不大,就直接注釋掉了,我主要用mp4live 

好,編譯成功,make install 即可使用。

三、安裝使用

1、安裝

make install

2、使用mp4live

Copyright © Linux教程網 All Rights Reserved