Skip to content

Commit

Permalink
UI: Use advanced mode audio track in multitrack video output
Browse files Browse the repository at this point in the history
  • Loading branch information
palana authored and RytoEX committed Jun 18, 2024
1 parent 48b1298 commit fb3e571
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
16 changes: 9 additions & 7 deletions UI/multitrack-video-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ SetupOBSOutput(obs_data_t *dump_stream_to_file_config,
const GoLiveApi::Config &go_live_config,
std::vector<OBSEncoderAutoRelease> &audio_encoders,
std::shared_ptr<obs_encoder_group_t> &video_encoder_group,
const char *audio_encoder_id,
const char *audio_encoder_id, size_t main_audio_mixer,
std::optional<size_t> vod_track_mixer);
static void SetupSignalHandlers(bool recording, MultitrackVideoOutput *self,
obs_output_t *output, OBSSignal &start,
Expand All @@ -348,7 +348,7 @@ void MultitrackVideoOutput::PrepareStreaming(
std::optional<uint32_t> maximum_aggregate_bitrate,
std::optional<uint32_t> maximum_video_tracks,
std::optional<std::string> custom_config,
obs_data_t *dump_stream_to_file_config,
obs_data_t *dump_stream_to_file_config, size_t main_audio_mixer,
std::optional<size_t> vod_track_mixer)
{
{
Expand Down Expand Up @@ -467,7 +467,8 @@ void MultitrackVideoOutput::PrepareStreaming(
std::shared_ptr<obs_encoder_group_t> video_encoder_group;
auto outputs = SetupOBSOutput(dump_stream_to_file_config, output_config,
audio_encoders, video_encoder_group,
audio_encoder_id, vod_track_mixer);
audio_encoder_id, main_audio_mixer,
vod_track_mixer);
auto output = std::move(outputs.output);
auto recording_output = std::move(outputs.recording_output);
if (!output)
Expand Down Expand Up @@ -728,7 +729,7 @@ static void
create_audio_encoders(const GoLiveApi::Config &go_live_config,
std::vector<OBSEncoderAutoRelease> &audio_encoders,
obs_output_t *output, obs_output_t *recording_output,
const char *audio_encoder_id,
const char *audio_encoder_id, size_t main_audio_mixer,
std::optional<size_t> vod_track_mixer)
{
using encoder_configs_type =
Expand Down Expand Up @@ -768,7 +769,8 @@ create_audio_encoders(const GoLiveApi::Config &go_live_config,
};

create_encoders("multitrack video live audio",
go_live_config.audio_configurations.live, 0);
go_live_config.audio_configurations.live,
main_audio_mixer);

if (!vod_track_mixer.has_value())
return;
Expand All @@ -787,7 +789,7 @@ SetupOBSOutput(obs_data_t *dump_stream_to_file_config,
const GoLiveApi::Config &go_live_config,
std::vector<OBSEncoderAutoRelease> &audio_encoders,
std::shared_ptr<obs_encoder_group_t> &video_encoder_group,
const char *audio_encoder_id,
const char *audio_encoder_id, size_t main_audio_mixer,
std::optional<size_t> vod_track_mixer)
{

Expand All @@ -803,7 +805,7 @@ SetupOBSOutput(obs_data_t *dump_stream_to_file_config,

create_audio_encoders(go_live_config, audio_encoders, output,
recording_output, audio_encoder_id,
vod_track_mixer);
main_audio_mixer, vod_track_mixer);

return {std::move(output), std::move(recording_output)};
}
Expand Down
1 change: 1 addition & 0 deletions UI/multitrack-video-output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct MultitrackVideoOutput {
std::optional<uint32_t> maximum_video_tracks,
std::optional<std::string> custom_config,
obs_data_t *dump_stream_to_file_config,
size_t main_audio_mixer,
std::optional<size_t> vod_track_mixer);
signal_handler_t *StreamingSignalHandler();
void StartedStreaming();
Expand Down
20 changes: 12 additions & 8 deletions UI/window-basic-main-outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ FutureHolder<bool> SimpleOutput::SetupStreaming(obs_service_t *service)
: std::nullopt;

auto holder = SetupMultitrackVideo(
service, GetSimpleAACEncoderForBitrate(audio_bitrate),
service, GetSimpleAACEncoderForBitrate(audio_bitrate), 0,
vod_track_mixer);
auto future =
PreventFutureDeadlock(holder.future)
Expand Down Expand Up @@ -2286,9 +2286,13 @@ FutureHolder<bool> AdvancedOutput::SetupStreaming(obs_service_t *service)

const char *audio_encoder_id =
config_get_string(main->Config(), "AdvOut", "AudioEncoder");
int streamTrackIndex =
config_get_int(main->Config(), "AdvOut", "TrackIndex");

auto holder = SetupMultitrackVideo(service, audio_encoder_id,
VodTrackMixerIdx(service));
auto holder =
SetupMultitrackVideo(service, audio_encoder_id,
static_cast<size_t>(streamTrackIndex),
VodTrackMixerIdx(service));
auto future =
PreventFutureDeadlock(holder.future)
.then(main, [&](std::optional<bool>
Expand Down Expand Up @@ -2701,10 +2705,9 @@ std::string BasicOutputHandler::GetRecordingFilename(

extern std::string DeserializeConfigText(const char *text);

FutureHolder<std::optional<bool>>
BasicOutputHandler::SetupMultitrackVideo(obs_service_t *service,
std::string audio_encoder_id,
std::optional<size_t> vod_track_mixer)
FutureHolder<std::optional<bool>> BasicOutputHandler::SetupMultitrackVideo(
obs_service_t *service, std::string audio_encoder_id,
size_t main_audio_mixer, std::optional<size_t> vod_track_mixer)
{
if (!multitrackVideo)
return {[] {}, CreateFuture().then([] {
Expand Down Expand Up @@ -2784,7 +2787,8 @@ BasicOutputHandler::SetupMultitrackVideo(obs_service_t *service,
audio_encoder_id.c_str(),
maximum_aggregate_bitrate,
maximum_video_tracks, custom_config,
stream_dump_config, vod_track_mixer);
stream_dump_config, main_audio_mixer,
vod_track_mixer);
} catch (const MultitrackVideoError &error) {
return error;
}
Expand Down
7 changes: 3 additions & 4 deletions UI/window-basic-main-outputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ struct BasicOutputHandler {
bool overwrite, const char *format,
bool ffmpeg);

FutureHolder<std::optional<bool>>
SetupMultitrackVideo(obs_service_t *service,
std::string audio_encoder_id,
std::optional<size_t> vod_track_mixer);
FutureHolder<std::optional<bool>> SetupMultitrackVideo(
obs_service_t *service, std::string audio_encoder_id,
size_t main_audio_mixer, std::optional<size_t> vod_track_mixer);
OBSDataAutoRelease GenerateMultitrackVideoStreamDumpConfig();
};

Expand Down

0 comments on commit fb3e571

Please sign in to comment.