加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

ffmpeg x264编译与编码常见的错误总结

(2016-03-16 08:42:35)
分类: 2016-03
问题1:
我用的是最新版本的ffmpegx264,刚刚编译出来,编译没有问题,但是在linux 环境使用ffmpeg的库时发现报错
error C3861: 'UINT64_C': identifier not found

解决方法在libavutil目录下的common.h里增加如下定义:

#ifndef INT64_C 
#define INT64_C(c) (c ## LL) 
#define UINT64_C(c) (c ## ULL) 
#endif

问题2:链接基于ffmpeg的应用时报错:
/usr/local/lib/libavcodec.a(libx264.o): In function `X264_frame':
/home/qiuzhongming/disk2/source_pc/ffmpeg-0.6/libavcodec/libx264.c:105: undefined reference to `x264_encoder_encode'
/usr/local/lib/libavcodec.a(libx264.o): In function `X264_close':
/home/qiuzhongming/disk2/source_pc/ffmpeg-0.6/libavcodec/libx264.c:143: undefined reference to `x264_encoder_close'
/usr/local/lib/libavcodec.a(libx264.o): In function `X264_init':
/home/qiuzhongming/disk2/source_pc/ffmpeg-0.6/libavcodec/libx264.c:153: undefined reference to `x264_param_default'
/home/qiuzhongming/disk2/source_pc/ffmpeg-0.6/libavcodec/libx264.c:295: undefined reference to `x264_encoder_open_83'
/home/qiuzhongming/disk2/source_pc/ffmpeg-0.6/libavcodec/libx264.c:305: undefined reference to `x264_encoder_headers'
collect2: ld returned 1 exit status

解决方法是:编译时候没有带上x264库,带上就好了。

问题3:使用ffmpeg x264进行编码的时候,avcodec_open报错:
[libx264 @ 00021bb0]broken ffmpeg default settings detected
[libx264 @ 00021bb0]use an encoding preset (vpre)
解决方法:在 x264 的source file encoder/encoder.c 中找到该报错的地方

    {
        int score = 0;
        score += h->param.analyse.i_me_range == 0;
        score += h->param.rc.i_qp_step == 3;
        score += h->param.i_keyint_max == 12;
        score += h->param.rc.i_qp_min == 2;
        score += h->param.rc.i_qp_max == 31;
        score += h->param.rc.f_qcompress == 0.5;
        score += fabs(h->param.rc.f_ip_factor - 1.25) < 0.01;
        score += fabs(h->param.rc.f_pb_factor - 1.25) < 0.01;
        score += h->param.analyse.inter == 0 && h->param.analyse.i_subpel_refine == 8;
        if( score >= 5 )
        {
            x264_log( h, X264_LOG_ERROR, "broken ffmpeg default settings detected\n" );
            x264_log( h, X264_LOG_ERROR, "use an encoding preset (vpre)\n" );
            return -1;
        }
    }

We can see that if score >= 5,the function to open the codec will fail.
We must at least set 4 param of the AVCodecContext before open it.
avcodec_open函数之间增加如下几个AVCodecContext 的初始化:

        ctx->me_range = 16;
        ctx->max_qdiff = 4;
        ctx->qmin = 10;
        ctx->qmax = 51;
        ctx->qcompress = 0.6; 

OK,解决。

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有