AVCodec*codec = avcodec_find_encoder_by_name("h264_qsv");
AVCodecContext* context = avcodec_alloc_context3(codec);
context->has_b_frames = 0;
context->max_b_frames = 0;
context->gop_size = 1;
context->keyint_min = 1;
设置x264_param_t.b_intra_refresh=0,此参数作用是将I帧拆成一个一个I块,然后放到P帧中,这样做的好处是保证每一帧大小都不超过UDP/TCP包大小,设置为0禁用此功能
av_opt_set(context->priv_data, "intra-refresh", "0", 0);
av_opt_set(context->priv_data, "trne", "zerolatency", 0);
av_opt_set(context->priv_data, "preset", "slow", 0);
avcodec_open2(context, codec, NULL);
av_opt_set(context->priv_data, "min-keyint", "10", 0);//设置x264_param_t.i_keyint_min=10
av_opt_set(context->priv_data, "keyint", "10", 0);//设置x264_param_t.i_keyint_max=10
x264_param_t.i_keyint_min和x264_param_t.i_keyint_max需要相同(也可以是10以外的数)