1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

lavc/libx265: Use avctx->framerate first for frame rate setting

perfer avctx->framerate first than use avctx->time_base when setting
the frame rate to encoder. 1/time_base is not the average frame rate
if the frame rate is not constant, so use avctx->framerate if the
value is not zero.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
Jun Zhao 2019-04-27 18:52:57 +08:00
parent 1e6338c2da
commit 68bac50604

View File

@ -110,8 +110,13 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
}
ctx->params->frameNumThreads = avctx->thread_count;
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
ctx->params->fpsNum = avctx->framerate.num;
ctx->params->fpsDenom = avctx->framerate.den;
} else {
ctx->params->fpsNum = avctx->time_base.den;
ctx->params->fpsDenom = avctx->time_base.num * avctx->ticks_per_frame;
}
ctx->params->sourceWidth = avctx->width;
ctx->params->sourceHeight = avctx->height;
ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR);