Skip to content

Commit e116690

Browse files
committed
multitrack: resolve squished image on w/Twitch enhanced + Dual Output
* fix issue dual output + enhanced broadcast (Twitch set vertical) * pass canvases into SetupOBSOutput * lookup ovi* using canvax_index Repro steps: In dual output, set horizontal to any platform and Twitch to vertical platform Enable enhanced broadcasting Go Live Check feed on Twitch. You'll see stream with vertical video settings and content from horizontal display
1 parent dbbf49d commit e116690

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

obs-studio-server/source/nodeobs_service.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,8 +1400,8 @@ bool OBS_service::startMultiTrackStreaming(StreamServiceId serviceId, bool dualS
14001400

14011401
std::vector<OBSEncoderAutoRelease> audio_encoders;
14021402
std::shared_ptr<obs_encoder_group_t> video_encoder_group;
1403-
auto output =
1404-
osn::SetupOBSOutput("Enhanced Broadcasting", go_live_config.value(), audio_encoders, video_encoder_group, audio_encoder_id, 0, vod_track_mixer);
1403+
auto output = osn::SetupOBSOutput("Enhanced Broadcasting", go_live_config.value(), audio_encoders, video_encoder_group, audio_encoder_id, 0,
1404+
vod_track_mixer, canvases);
14051405
if (!output) {
14061406
throw std::runtime_error("startStreaming - failed to create multitrack output");
14071407
}

obs-studio-server/source/osn-enhanced-broadcasting.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ template<typename BaseStreaming> class EnhancedBroadcasting : public BaseStreami
8181
std::vector<OBSEncoderAutoRelease> audio_encoders;
8282
std::shared_ptr<obs_encoder_group_t> video_encoder_group;
8383
auto output = osn::SetupOBSOutput("Enhanced Broadcasting", go_live_config.value(), audio_encoders, video_encoder_group, audio_encoder_id, 0,
84-
vod_track_mixer);
84+
vod_track_mixer, canvases);
8585
if (!output) {
8686
throw std::runtime_error("startStreaming - failed to create multitrack output");
8787
}

obs-studio-server/source/osn-multitrack-video-output.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

322322
OBSOutputAutoRelease 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;

obs-studio-server/source/osn-multitrack-video-output.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace osn {
1313

1414
OBSOutputAutoRelease SetupOBSOutput(const std::string &multitrack_video_name, const Config &go_live_config, std::vector<OBSEncoderAutoRelease> &audio_encoders,
1515
std::shared_ptr<obs_encoder_group_t> &video_encoder_group, const char *audio_encoder_id, size_t main_audio_mixer,
16-
std::optional<size_t> vod_track_mixer);
16+
std::optional<size_t> vod_track_mixer, const std::vector<obs_video_info *> &canvases);
1717

1818
OBSServiceAutoRelease create_service(const Config &go_live_config, const std::optional<std::string> &rtmp_url, const std::string &in_stream_key);
1919

0 commit comments

Comments
 (0)