kvazaar
kvazaar copied to clipboard
ffmpeg codes use kvazaar
hi , im change command line to codes use ffmpeg libkvazaar ,i cant find codec_ID for libkvazaar, should i use AV_CODEC_ID_HEVC? or other codec_id
my codes like :
const AVCodec *avCodec = avcodec_find_encoder(AV_CODEC_ID_HEVC); AVCodecContext *avCodecContext = avcodec_alloc_context3(avCodec); avCodecContext->time_base = {1,25};
avCodecContext->width = 3480;
avCodecContext->height = 1920;
avCodecContext->bit_rate = 10485760;
//avCodecContext->profile = FF_PROFILE_H264_MAIN;
avCodecContext->gop_size = 10;
avCodecContext->time_base = {1,25};
avCodecContext->framerate = {25,1};
avCodecContext->max_b_frames = 1;
avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
av_opt_set(avCodecContext->priv_data,"preset","ultrafast",0);
av_opt_set(avCodecContext->priv_data,"tiles","1x3",0);
av_opt_set(avCodecContext->priv_data,"slices","tiles",0);
av_opt_set(avCodecContext->priv_data,"mv-constraint","tiles",0);
int ret = avcodec_open2(avCodecContext,avCodec, nullptr);
if(ret < 0){
std::cout << "open encoder fail:" << strerror(ret) << std::endl;
return;
}
how can i change kvazaar-paramers into code (--cpuid --input-fps 30 --bitrate 10485760 --period 30 --preset ultrafast --erp-aqp --input-res 3840x1920 --no-open-gop --gop lp-g30d1t1 --tiles 1x3 --slices tiles --mv-constraint frametilemargin --no-bipred) just use like this {av_opt_set(avCodecContext->priv_data,"tiles","1x3",0);}?
i cant find avcodec_find_encoder_by_name("libkvazaar") , used wrong?
You have to pack this parameters to string "input-fps=30,bitrate=104..."
and then do
av_dict_set(&options, "kvazaar-params", options_string, 0)
Where options
is an AVDictionary
which you will later pass to
avcodec_open2(context, codec, &options)
The answer might depend on version of ffmpeg. You can set some of the parameters via context->
, but they are overriden by parameters in the options
later.
See source code: https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libkvazaar.c
Read the friendly manual: ffmpeg -h encoder=libkvazaar
i cant find avcodec_find_encoder_by_name("libkvazaar") , used wrong?
This is right. If ffmpeg can't find the encoder, that could mean that you built the ffmpeg library without kvazaar.