[ffmpeg] 获取编码后视频的IPB帧类型
背景
如何获取编码后的视频帧类型
(图片来源网络,侵删)
方法
uint8_t* data = NULL; size_t size = 0; data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &size); type = (enum AVPictureType)data[4]; cout // .... switch (pic_out.i_type) { case X264_TYPE_IDR: case X264_TYPE_I: pict_type = AV_PICTURE_TYPE_I; break; case X264_TYPE_P: pict_type = AV_PICTURE_TYPE_P; break; case X264_TYPE_B: case X264_TYPE_BREF: pict_type = AV_PICTURE_TYPE_B; break; default: av_log(ctx, AV_LOG_ERROR, "Unknown picture type encountered.\n"); return AVERROR_EXTERNAL; } pkt-flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe; if (ret) { ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA, NULL, 0, pict_type); if (wallclock) ff_side_data_set_prft(pkt, wallclock); } *got_packet = ret; return 0; } int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) { uint8_t *side_data; size_t side_data_size; int i; side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size); if (!side_data) { side_data_size = 4+4+8*error_count; side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, side_data_size); } if (!side_data || side_data_size
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。