From c0f71f002ce2a30d669ff7316ef45450ddbeaeaf Mon Sep 17 00:00:00 2001 From: Alex Luccisano Date: Thu, 15 Feb 2024 15:01:56 -0500 Subject: [PATCH] obs-ffmpeg: Use video_output_info in amf_create_encoder() The frame rate used to initialize an AMF encoder should be aligned with the derived frame rate in video_output_info instead of the global obs_video_info structure. With this change, IDRs can be aligned when multiple renditions are being encoded. Using video_output_info members for the format, colorspace, and range parameters in addition to the frame rate provides a single source for this information and obs_video_info is no longer needed. --- plugins/obs-ffmpeg/texture-amf.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/obs-ffmpeg/texture-amf.cpp b/plugins/obs-ffmpeg/texture-amf.cpp index 7a698931b..0bdc71cc5 100644 --- a/plugins/obs-ffmpeg/texture-amf.cpp +++ b/plugins/obs-ffmpeg/texture-amf.cpp @@ -991,13 +991,12 @@ try { /* ------------------------------------ */ /* get video info */ - struct obs_video_info ovi; - obs_get_video_info(&ovi); - struct video_scale_info info; - info.format = ovi.output_format; - info.colorspace = ovi.colorspace; - info.range = ovi.range; + video_t *video = obs_encoder_video(enc->encoder); + const struct video_output_info *voi = video_output_get_info(video); + info.format = voi->format; + info.colorspace = voi->colorspace; + info.range = voi->range; if (enc->fallback) { if (enc->codec == amf_codec_type::AVC) @@ -1010,9 +1009,9 @@ try { enc->cx = obs_encoder_get_width(enc->encoder); enc->cy = obs_encoder_get_height(enc->encoder); - enc->amf_frame_rate = AMFConstructRate(ovi.fps_num, ovi.fps_den); - enc->fps_num = (int)ovi.fps_num; - enc->fps_den = (int)ovi.fps_den; + enc->amf_frame_rate = AMFConstructRate(voi->fps_num, voi->fps_den); + enc->fps_num = (int)voi->fps_num; + enc->fps_den = (int)voi->fps_den; enc->full_range = info.range == VIDEO_RANGE_FULL; switch (info.colorspace) {