@@ -172,7 +172,8 @@ static OBSEncoderAutoRelease create_video_encoder(DStr &name_buffer, std::size_t
172172 return video_encoder;
173173}
174174
175- static bool create_video_encoders (const Config &go_live_config, std::shared_ptr<obs_encoder_group_t > &video_encoder_group, obs_output_t *output)
175+ static bool create_video_encoders (const Config &go_live_config, std::shared_ptr<obs_encoder_group_t > &video_encoder_group, obs_output_t *output,
176+ const std::vector<obs_video_info *> &canvases)
176177{
177178 DStr video_encoder_name_buffer;
178179 if (go_live_config.encoder_configurations .empty ()) {
@@ -186,18 +187,17 @@ static bool create_video_encoders(const Config &go_live_config, std::shared_ptr<
186187 return false ;
187188 }
188189
189- const auto max_canvas_idx = obs_get_video_info_count () - 1 ;
190-
191190 for (size_t i = 0 ; i < go_live_config.encoder_configurations .size (); i++) {
192191 auto &config = go_live_config.encoder_configurations [i];
193- if (config.canvas_index > max_canvas_idx) {
194- blog (LOG_ERROR, " create_video_encoders - got unexpected large canvas index - i: %d" , config.canvas_index );
192+ if (config.canvas_index >= canvases.size ()) {
193+ blog (LOG_ERROR, " create_video_encoders - canvas_index %d out of range (canvases.size()=%zu) - encoder: %zu" , config.canvas_index ,
194+ canvases.size (), i);
195195 return false ;
196196 }
197197
198- obs_video_info *ovi = obs_get_video_info_by_index2 ( config.canvas_index ) ;
198+ obs_video_info *ovi = canvases[ config.canvas_index ] ;
199199 if (!ovi) {
200- blog (LOG_ERROR, " create_video_encoders - failed to get canvas video info by index - i : %d " , config.canvas_index );
200+ blog (LOG_ERROR, " create_video_encoders - null canvas at index %d - encoder : %zu " , config.canvas_index , i );
201201 return false ;
202202 }
203203
@@ -321,12 +321,12 @@ static OBSOutputAutoRelease create_output()
321321
322322OBSOutputAutoRelease SetupOBSOutput (const std::string &multitrack_video_name, const Config &go_live_config, std::vector<OBSEncoderAutoRelease> &audio_encoders,
323323 std::shared_ptr<obs_encoder_group_t > &video_encoder_group, const char *audio_encoder_id, size_t main_audio_mixer,
324- std::optional<size_t > vod_track_mixer)
324+ std::optional<size_t > vod_track_mixer, const std::vector<obs_video_info *> &canvases )
325325{
326326
327327 auto output = create_output ();
328328
329- if (!create_video_encoders (go_live_config, video_encoder_group, output))
329+ if (!create_video_encoders (go_live_config, video_encoder_group, output, canvases ))
330330 return nullptr ;
331331
332332 std::vector<speaker_layout> requested_speaker_layouts;
0 commit comments