一、环境@H_404_4@@H_404_4@@H_404_4@
1@H_404_4@、操作系统版本@H_404_4@@H_404_4@@H_404_4@
CentOS 6.2 64@H_404_4@位@H_404_4@@H_404_4@@H_404_4@
uname -a@H_404_4@的输出:@H_404_4@@H_404_4@@H_404_4@
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@H_404_4@@H_404_4@
2@H_404_4@、@H_404_4@@H_404_4@mpeg4ip@H_404_4@版本@H_404_4@@H_404_4@@H_404_4@
版本:@H_404_4@@H_404_4@1.6.1@H_404_4@@H_404_4@
下载链接:@H_404_4@@H_404_4@@H_404_4@
http://people.freebsd.org/~ahze/distfiles/mpeg4ip-1.6.1.tar.gz@H_404_4@@H_404_4@
二、编译@H_404_4@@H_404_4@@H_404_4@
1@H_404_4@、编译mpeg4ip@H_404_4@需要的库
首先安装@H_404_4@libtool@H_404_4@@H_404_4@库,命令如下:@H_404_4@@H_404_4@
yum install libtool@H_404_4@
然后进入到mpeg4ip@H_404_4@的目录,运行./bootstrap@H_404_4@进行配置,如果出错,是因为bash@H_404_4@版本及名称的问题,修改bootstrap@H_404_4@文件中第一行,改sh @H_404_4@为bash.@H_404_4@或运行 bash ./bootstrap@H_404_4@。
提示如下:
*** 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@H_404_4@
yum install ffmpeg-devel xvidcore-devel twolame-devel x264-devel@H_404_4@@H_404_4@@H_404_4@
编译:@H_404_4@@H_404_4@make@H_404_4@
2@H_404_4@@H_404_4@、编译中的错误处理@H_404_4@@H_404_4@
2.1 @H_404_4@@H_404_4@报错内容:@H_404_4@@H_404_4@
In file included from config_opts.cpp:1: /include/mpeg4ip.h:@H_404_4@126: error: new declaration 'char* strcasestr(const char*, const char*)' /usr/include/string.h:@H_404_4@369: error: ambiguates old declaration 'const char* strcasestr(const char*,const char*)'
vi include/mpeg4ip.h@H_404_4@@H_404_4@@H_404_4@
注释掉函数声明,如下所示:@H_404_4@@H_404_4@
cc1plus: warnings being treated as errors sys_decoder_blkdec.cpp:@H_404_4@190: error: suggest parentheses around '&&' within '||' sys_decoder_blkdec.cpp:@H_404_4@205: error: suggest parentheses around '&&' within '||'
如图所示:
vi common/video/iso-mpeg4/src/Makefile@H_404_4@
去掉Werror@H_404_4@
vi@H_404_4@命令:@H_404_4@%s/-Werror//@H_404_4@
type_basic.cpp:320: error: '<anonymous>' has incomplete type type_basic.cpp:@H_404_4@320: error: invalid use of 'Void' type_basic.cpp:@H_404_4@320: error: prototype for 'Void CMotionVector::setToZero(<type error>)' does not match any in class 'CMotionVector' ./../include/basic.hpp:@H_404_4@441: error: candidate is: Void CMotionVector::setToZero()
vi common/video/iso-mpeg4/src/type_basic.cpp@H_404_4@
在@H_404_4@320@H_404_4@行去掉括号内的@H_404_4@Void@H_404_4@,如图所示:@H_404_4@
cc1: warnings being treated as errors config.c: In function 'enter_chn': config.c:@H_404_4@636: error: array subscript is above array bounds config.c:@H_404_4@637: error: array subscript is above array bounds
vi player/lib/audio/faad/Makefile@H_404_4@
去掉@H_404_4@2.5 @H_404_4@报错内容:@H_404_4@
/usr/local/include/libavutil/common.h: In function ‘int32_t av_clipl_int32(int64_t)’: /usr/local/include/libavutil/common.h:@H_404_4@154: error: ‘UINT64_C’ was not declared in this scope ...@H_404_4@
涉及到标准c@H_404_4@和c99@H_404_4@的问题,在出问题的文件中加上下面三句话就好了
2.6 @H_404_4@报错内容:@H_404_4@@H_404_4@@H_404_4@
In file included from ffmpeg.cpp:26: ffmpeg.h:@H_404_4@29:28: error: ffmpeg/avcodec.h: No such file or directory ...@H_404_4@
版本遗留问题,修改下路径就行了。其实这是一类问题,接下来还会遇到好多次,以这个为例展例下,其它的照此修改就OK了。@H_404_4@
vi player/plugin/audio/ffmpeg/ffmpeg.h@H_404_4@
在第@H_404_4@30@H_404_4@@H_404_4@行进行修改,替换成完整路径:@H_404_4@
#include <ffmpeg-spice/libavcodec/avcodec.h>@H_404_4@
2.7@H_404_4@报错内容:@H_404_4@@H_404_4@
ffmpeg.cpp: In function 'codec_data_t* ffmpeg_create(const char*,const char*,int,format_list_t*,audio_info_t*,const uint8_t*,uint32_t,audio_vft_t*, void*)': ffmpeg.cpp:@H_404_4@180: error: 'AVCODEC_MAX_AUdio_FRAME_SIZE' was not declared in this scope ffmpeg.cpp: In function 'int ffmpeg_decode(codec_data_t*@H_404_4@,frame_timestamp_t*,int*,uint8_t*,void*)':
vi /usr/include/ffmpeg-spice/libavcodec/avcodec.h@H_404_4@@H_404_4@
查找 @H_404_4@AVCODEC_MAX_AUdio_FRAME_SIZE@H_404_4@@H_404_4@,得到如下结果:@H_404_4@
复制其值到文件@H_404_4@player/plugin/audio/ffmpeg/ffmpeg.h@H_404_4@@H_404_4@,并把@H_404_4@Q@H_404_4@@H_404_4@去掉:@H_404_4@
vi player/plugin/audio/ffmpeg/ffmpeg.h@H_404_4@
#define AVCODEC_MAX_AUdio_FRAME_SIZE 192000@H_404_4@
2.8 @H_404_4@@H_404_4@报错内容:@H_404_4@
media_utils.cpp: In function 'int create_media_for_iptv(CPlayerSession*, control_callback_vft_t*)': media_utils.cpp:@H_404_4@613: error: invalid conversion from 'const char*' to 'char*'
vi player/src/media_utils.cpp@H_404_4@@H_404_4@
在@H_404_4@613@H_404_4@@H_404_4@行,对@H_404_4@name@H_404_4@@H_404_4@变量进行强制类型转换,如图所示:@H_404_4@
2.9 @H_404_4@报错内容:@H_404_4@@H_404_4@
../server/mp4live/video_util_resize.h:93: error: conflicting declaration 'uint8_t* fV' ../server/mp4live/video_util_resize.h:@H_404_4@91: error: 'fV' has a prevIoUs declaration as 'const uint8_t* fV' ../server/mp4live/video_util_resize.h:@H_404_4@94: error: redefinition of 'uint32_t tvStride' ../server/mp4live/video_util_resize.h:@H_404_4@94: error: 'uint32_t tvStride' prevIoUsly declared here
@H_404_4@这个就是函数声明的时候变量重名了,把名字修改的不同就@H_404_4@OK@H_404_4@@H_404_4@了。@H_404_4@这是我修改:@H_404_4@
void@H_404_4@CopyYuv(const@H_404_4@uint8_t*fY,const@H_404_4@uint8_t*fU,const@H_404_4@uint8_t*fV,uint32_tfyStride,uint32_tfuStride,uint32_tfvStride2,uint8_t@H_404_4@*tY,uint8_t*tU,uint8_t*fV2,uint32_ttyStride,uint32_ttvStride,uint32_ttvStride2,uint32_tw,uint32_th); @H_404_4@
video_ffmpeg.cpp:124: error: 'struct AVCodecContext' has no member named 'frame_rate' video_ffmpeg.cpp:@H_404_4@125: error: 'struct AVCodecContext' has no member named 'frame_rate_base' video_ffmpeg.cpp:@H_404_4@136: error: 'struct AVCodecContext' has no member named 'aspect_ratio'
vi server/mp4live/video_ffmpeg.cpp@H_404_4@
@H_404_4@
好,编译成功,@H_404_4@make install @H_404_4@@H_404_4@即可使用。@H_404_4@
三、安装使用@H_404_4@
1@H_404_4@@H_404_4@、安装@H_404_4@
make install@H_404_4@