Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg codes use kvazaar #370

Open
lyk941031 opened this issue Aug 30, 2023 · 5 comments
Open

ffmpeg codes use kvazaar #370

lyk941031 opened this issue Aug 30, 2023 · 5 comments

Comments

@lyk941031
Copy link

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 :

@lyk941031
Copy link
Author

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;
}

@lyk941031
Copy link
Author

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);}?

@lyk941031
Copy link
Author

i cant find avcodec_find_encoder_by_name("libkvazaar") , used wrong?

@pinbraerts
Copy link

pinbraerts commented Aug 23, 2024

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

@pinbraerts
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants