OpenVisualCloud / SVT-HEVC

SVT HEVC encoder. Scalable Video Technology (SVT) is a software-based video coding technology that is highly optimized for Intel® Xeon® processors. Using the open source SVT-HEVC encoder, it is possible to spread video encoding processing across multiple Intel® Xeon® processors to achieve a real advantage of processing efficiency.
Other
507 stars 169 forks source link

configure encoder parameters cpp #589

Closed Timorleiderman closed 3 years ago

Timorleiderman commented 3 years ago

I am using cpp with ffmpeg and svt-hevc I want to configure encMode and QP parameters

what am I doing wrong?

this is a sample of my code:

int ret;
const AVCodec *codec;
AVCodecContext *c= NULL;
codec = avcodec_find_encoder_by_name("libsvt_hevc");

c = avcodec_alloc_context3(codec);

AVCodecParameters *params = NULL;
params = avcodec_parameters_alloc();

c->codec_type = AVMEDIA_TYPE_VIDEO;
ret = avcodec_parameters_from_context(params, c);

c->width = 512;
c->height = 768;
c->gop_size = 30;
c->pix_fmt = AV_PIX_FMT_YUV420P;
c->time_base= (AVRational){1,30};

av_opt_set(c,"encMode", "11", 0); // <- this does not work

if (avcodec_open2(c, codec, &opts) < 0)
    std::cout << "could not open codec" << std::endl;
tianjunwork commented 3 years ago

Hi @Timorleiderman , https://github.com/OpenVisualCloud/SVT-HEVC/blob/master/ffmpeg_plugin/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch#L586 please use preset instead. For your input resolution, the highest preset is 9. https://github.com/OpenVisualCloud/SVT-HEVC/blob/master/Docs/svt-hevc_encoder_user_guide.md#encoding-presets-table

For QP: https://github.com/OpenVisualCloud/SVT-HEVC/blob/master/ffmpeg_plugin/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch#L592.

Timorleiderman commented 3 years ago

Thank you this worked for me :) av_opt_set(c->priv_data, "preset", "9",0); av_opt_set(c->priv_data, "qp", "20",0);

tianjunwork commented 3 years ago

No problem:)