Commit b18fd2b9 authored by Zachariah Brown's avatar Zachariah Brown Committed by Timo Rothenpieler

avcodec/nvenc: use framerate if available

The h264_nvenc and hevc_nvenc encoders aren't respecting the framerate in the codec context.
Instead it was using the timebase which in our use-case was 1/1000 so the encoder was behaving
as if we wanted 1000fps. This resulted in poor encoding results due to an extremely low bitrate.

Both the amf and qsv encoders already contain similar logic to first check the framerate before
falling back to the timebase.
Signed-off-by: 's avatarZachariah Brown <zachariah@renewedvision.com>
Signed-off-by: 's avatarTimo Rothenpieler <timo@rothenpieler.org>
parent b7d89963
...@@ -1209,8 +1209,13 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx) ...@@ -1209,8 +1209,13 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
ctx->init_encode_params.darHeight = dh; ctx->init_encode_params.darHeight = dh;
ctx->init_encode_params.darWidth = dw; ctx->init_encode_params.darWidth = dw;
ctx->init_encode_params.frameRateNum = avctx->time_base.den; if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame; ctx->init_encode_params.frameRateNum = avctx->framerate.num;
ctx->init_encode_params.frameRateDen = avctx->framerate.den;
} else {
ctx->init_encode_params.frameRateNum = avctx->time_base.den;
ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame;
}
ctx->init_encode_params.enableEncodeAsync = 0; ctx->init_encode_params.enableEncodeAsync = 0;
ctx->init_encode_params.enablePTD = 1; ctx->init_encode_params.enablePTD = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment