在硬编码的时候,会在每一帧前都有一个SEI 00 00 00 01 06
用命令行测试也还是会有SEI,主要是比较占我使用的空间大小,影响我码率吧,二来也是看起来不爽。所以想把他去掉,其实不去掉好像也没啥影响。
而测试了软编码没有,也确定了硬编码是可以不出现SEI的,所以找找源码到底是哪里出问题,怎么去掉SEI。
当然是看nvenc.c了
一看是以为是ff_nvenc_send_frame里的a53_cc导致的,设置为0之后仍不生效。
int ff_nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
{
NvencContext *ctx = avctx->priv_data;
...
if (ctx->a53_cc && av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC)) {
if (ff_alloc_a53_sei(frame, sizeof(NV_ENC_SEI_PAYLOAD), (void**)&sei_data, &sei_size) < 0) {
av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n");
}
if (sei_data) {
sei_data->payloadSize = (uint32_t)sei_size;
sei_data->payloadType = 4;
sei_data->payload = (uint8_t*)(sei_data + 1);
}
}
nvenc_codec_specific_pic_params(avctx, &pic_params, sei_data);
...
}
只能看看有没有相关的SEI参数了,最终在nvEncodeAPI.h中找到几个有SEI字样的参数。
有个朋友给我提示了这个参数
--pic-struct Force pic_struct in Picture Timing SEI
但是这个是libx264才有的,我看了h264_nvenc没有这个设置
最终在函数nvenc_setup_h264_config中感觉h264->outputPictureTimingSEI = 1;就是我想要找的
这个配置好像没有可以外部去配置的,只能改下源码了
h264->outputPictureTimingSEI = 0;
编译,测试,成功.