0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

obs-ffmpeg: Set framerate for AVCodecContext outputs

In avcodec.h, the docs for AVCodecContext->framerate say:
encoding: May be used to signal the framerate of CFR content to an
          encoder.

OBS is designed to always output Constant Frame Rate (CFR) content.
Instead of letting this be implied, let's explicitly set the framerate
per the docs.
This commit is contained in:
Ryan Foster 2023-04-03 17:35:49 -04:00
parent 855d9cba4a
commit a973b97036
2 changed files with 2 additions and 0 deletions

View File

@ -256,6 +256,7 @@ static bool create_video_stream(struct ffmpeg_data *data)
context->width = data->config.scale_width;
context->height = data->config.scale_height;
context->time_base = (AVRational){ovi.fps_den, ovi.fps_num};
context->framerate = (AVRational){ovi.fps_num, ovi.fps_den};
context->gop_size = data->config.gop_size;
context->pix_fmt = closest_format;
context->color_range = data->config.color_range;

View File

@ -75,6 +75,7 @@ void ffmpeg_video_encoder_update(struct ffmpeg_video_encoder *enc, int bitrate,
enc->context->width = obs_encoder_get_width(enc->encoder);
enc->context->height = obs_encoder_get_height(enc->encoder);
enc->context->time_base = (AVRational){voi->fps_den, voi->fps_num};
enc->context->framerate = (AVRational){voi->fps_num, voi->fps_den};
enc->context->pix_fmt = pix_fmt;
enc->context->color_range = info->range == VIDEO_RANGE_FULL
? AVCOL_RANGE_JPEG