enc_ctx->profile =FF_PROFILE_H264_MAIN ;
enc_ctx->time_base.den = 24;
enc_ctx->time_base.num = 1;
enc_ctx->gop_size = 8; /* emit one intra frame every twelve frames at most */
enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
enc_ctx->max_b_frames = 0;
enc_ctx->has_b_frames = 0;
av_opt_set(enc_ctx->priv_data, "preset", "slow", 0); ///
av_opt_set(enc_ctx->priv_data, "tune", "zerolatency", 0);

enc_ctx->bit_rate = br ;
enc_ctx->rc_min_rate = br ;
enc_ctx->rc_max_rate = br ;
enc_ctx->bit_rate_tolerance = br;
enc_ctx->rc_buffer_size = br;
enc_ctx->rc_initial_buffer_occupancy = enc_ctx->rc_buffer_size*3/4;
enc_ctx->rc_buffer_aggressivity = (float)1.0;
enc_ctx->rc_initial_cplx = 0.5;
enc_ctx->i_quant_factor = -1;

基本设置,固定码率150k,enc_ctx->i_quant_factor默认为 -1,编码结果

[libx264 @ 005cbb40] frame I:38 Avg QP:36.34 size: 4044
[libx264 @ 005cbb40] frame P:262 Avg QP:35.27 size: 339

I的质量比P还差。

ffmpeg中i_quant_factor的解释

/**
* qscale factor between P and I-frames
* If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
* If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
* - encoding: Set by user.
* - decoding: unused
*/
float i_quant_factor;

enc_ctx->i_quant_factor = -0.7;时:

[libx264 @ 006ecb40] frame I:38 Avg QP:36.11 size: 4067
[libx264 @ 006ecb40] frame P:262 Avg QP:34.89 size: 337

enc_ctx->i_quant_factor = -1.4;时

[libx264 @ 0276cb40] frame I:38 Avg QP:35.34 size: 4439
[libx264 @ 0276cb40] frame P:262 Avg QP:35.17 size: 280

enc_ctx->i_quant_factor = -2;时

[libx264 @ 02beda40] frame I:38 Avg QP:34.59 size: 4155
[libx264 @ 02beda40] frame P:262 Avg QP:33.71 size: 323

i_quant_factor 相当于x264的参数ipratio

默认值:1.40

修改I帧量化值相比P帧量化值的目标平均增量。越大的值会提高I帧的品质。

原因估计:应该是i_quant_factor 绝对值越大,I帧质量越好。还有猜测可能是码率不够,限制了I帧的比特数。

设置固定码率300k时:

[libx264 @ 016dbb40] frame I:38 Avg QP:29.21 size: 6367
[libx264 @ 016dbb40] frame P:262 Avg QP:29.60 size: 622

ffmpeg,X264编码结果I帧QP比P帧还大的更多相关文章

  1. WebRTC VideoEngine超详细教程(三)——集成X264编码和ffmpeg解码

    转自:http://blog.csdn.net/nonmarking/article/details/47958395 本系列目前共三篇文章,后续还会更新 WebRTC VideoEngine超详细教 ...

  2. ffmpeg音频编码

    在弄音频采集时,需要设置缓存的大小,如果只是简单的采集和直接播放PCM数据,缓存的大小一般不影响播放和保存. 但是,如果需要使用FFMpeg音频编码,这时,音频缓存的大小必须设置av_samples_ ...

  3. (转)x264 编码流程

    转自:http://alphamailpost.blog.163.com/blog/static/20111808120128111160728/ http://www.usr.cc/thread-5 ...

  4. X264编码流程详解(转)

    http://blog.csdn.net/xingyu19871124/article/details/7671634 对H.264编码标准一直停留在理解原理的基础上,对于一个实际投入使用的编码器是如 ...

  5. 视频x264编码浅析

    声明 x264_param_t 结构体变量: x264_param_t params; x264_param_default_preset(&params, "ultrafast&q ...

  6. ffmpeg x264编译与使用介绍

    问题1:我用的是最新版本的ffmpeg和x264,刚刚编译出来,编译没有问题,但是在linux 环境使用ffmpeg的库时发现报错error C3861: 'UINT64_C': identifier ...

  7. ffmpeg x264安装

    fmpeg安装第三方编码器(encoder)库,ffmpeg编码h264(完) ffmpeg安装第三方编码器(encoder)库 关键词:ffmpeg.编码h264.第三方encoder 安装好了ff ...

  8. JavaCV FFmpeg AAC编码

    上次成功通过FFmpeg采集麦克风的PCM数据,这次针对上一次的程序进行了改造,使用AAC编码采集后的数据. (传送门) JavaCV FFmpeg采集麦克风PCM音频数据 采集麦克风数据是一个解码过 ...

  9. Android camera采集视频 X264编码

    参考 http://blog.csdn.net/zblue78/article/details/6058147 感谢 ExperiencesOfCode 硬件平台:CPU Intel G630 @2. ...

随机推荐

  1. U3D刚体测试3(constraints)

    程序这边的接口: mRigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.Freeze ...

  2. SecureCRT issue "Could not open clipboard: Assess is denied" (无法打开粘贴板:访问被拒绝)

    I got an issue when copying some line/word (actually just select the context ) in the Linux terminal ...

  3. Linux/Unix里,ln -s

    这是硬/软链接的命令ln -s 是创建软链接ln 是创建硬链接 你可以理解为:相当于windows下创建快捷方式一样,所以就不用太多解释了吧. ln -s /usr/lib/libX11.3 libX ...

  4. HTTP缓存机制

    缓存对于移动端是非常重要的存在. 减少请求次数,减小服务器压力. 本地数据读取速度更快,让页面不会空白几百毫秒. 在无网络的情况下提供数据. 缓存一般由服务器控制(通过某些方式可以本地控制缓存,比如向 ...

  5. Python 2.7.9 Demo - JSON的编码、解码

    #coding=utf-8 #!/usr/bin/python import json; dict = {}; dict['name'] = 'nick'; dict['say'] = 'hello ...

  6. stm32中断服务函数

    你打开stm32的启动文件,例如startup_stm32f10x_hd.s 里面有很多中断跳转的入口.用白话说就是固件库帮你写好了发生什么中断时跳转到哪里,这些名字是一个函数名,你要把这些函数写出来 ...

  7. 【leetcode❤python】171. Excel Sheet Column Number

    #-*- coding: UTF-8 -*- # ord(c) -> integer##Return the integer ordinal of a one-character string. ...

  8. chmod 无法修改磁盘文件的权限解释 (光盘文件就是只读的,修改不了的)

    我们知道root用户是linux执行权限最高的管理者用户,他可以进行任何的权限操作:然而我们的操作系统同样也考虑过这样的弊端,就是当我们使用者并不了解文件属性和重要性时会给予我们使用者提示: 举个例子 ...

  9. 粒子群算法 Particle Swarm Optimization, PSO(转贴收藏)

    粒子群算法(1)----粒子群算法简介 http://blog.csdn.net/niuyongjie/article/details/1569671 粒子群算法(2)----标准的粒子群算法 htt ...

  10. 使用Spring容器

    Spring的两个核心接口:BeanFactory和ApplicationContext,其中ApplicationContext是BeanFactory的子接口. Spring容器就是一个大的Bea ...