Skip to content

Commit c532953

Browse files
committed
add audio mixer selection for encoder
1 parent 5660746 commit c532953

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.16)
2-
project(obs-multi-rtmp VERSION 0.2.4)
2+
project(obs-multi-rtmp VERSION 0.2.5)
33

44
set(QTDIR "${QTDIR}" CACHE PATH "Path to qt directory")
55

locale/en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Bitrate="Bitrate"
1313
KeyFrame="Keyframe"
1414
Notice.CPUPower="Notice: Standalone encoder calls for more CPU power."
1515
AudioSettings="Audio Settings"
16+
AudioMixerID="Audio Mixer ID"
1617
kbps="kbps"
1718
OK="OK"
1819
SameAsOBS="Get from OBS"

locale/ja-JP.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Bitrate="ビットレート"
1111
KeyFrame="キーフレーム"
1212
Notice.CPUPower="お知らせ:独立ビデオエンコーダの使いは力技です。"
1313
AudioSettings="音声設定"
14+
AudioMixerID="音声ミクサーID"
1415
kbps="kbps"
1516
OK="OK"
1617
SameAsOBS="OBSから取得"

locale/zh-CN.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Bitrate="码率"
1313
KeyFrame="关键帧间隔"
1414
Notice.CPUPower="信息:使用独立编码器需要较好的电脑配置。"
1515
AudioSettings="声音设置"
16+
AudioMixerID="混音器编号"
1617
kbps="kbps"
1718
OK="OK"
1819
SameAsOBS="从OBS获取"

src/obs-multi-rtmp.cpp

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class EditOutputWidget : public QDialog
156156
QLabel* v_warning_ = 0;
157157
QComboBox* aenc_ = 0;
158158
QLineEdit* a_bitrate_ = 0;
159+
QComboBox* a_mixer_ = 0;
159160

160161
std::vector<std::string> EnumEncodersByCodec(const char* codec)
161162
{
@@ -311,8 +312,12 @@ class EditOutputWidget : public QDialog
311312
}
312313
++currow;
313314
{
314-
encLayout->addWidget(new QWidget(), currow, 0);
315-
encLayout->setRowStretch(currow, 1);
315+
int curcol = 0;
316+
encLayout->addWidget(new QLabel(obs_module_text("AudioMixerID"), gp), currow, curcol++);
317+
encLayout->addWidget(a_mixer_ = new QComboBox(gp), currow, curcol++);
318+
319+
for(int i = 1; i <= 6; ++i)
320+
a_mixer_->addItem(QString(std::to_string(i).c_str()), i - 1);
316321
}
317322
gp->setLayout(encLayout);
318323
}
@@ -393,10 +398,12 @@ class EditOutputWidget : public QDialog
393398
{
394399
a_bitrate_->setText(obs_module_text("SameAsOBS"));
395400
a_bitrate_->setEnabled(false);
401+
a_mixer_->setEnabled(false);
396402
}
397403
else
398404
{
399405
a_bitrate_->setEnabled(true);
406+
a_mixer_->setEnabled(true);
400407
}
401408
}
402409

@@ -417,6 +424,8 @@ class EditOutputWidget : public QDialog
417424
conf_["v-resolution"] = v_resolution_->text();
418425
if (a_bitrate_->isEnabled())
419426
try { conf_["a-bitrate"] = std::stod(tostdu8(a_bitrate_->text())); } catch(...) {}
427+
if (a_mixer_->isEnabled())
428+
conf_["a-mixer"] = a_mixer_->currentData().toDouble();
420429
}
421430

422431
void LoadConfig()
@@ -482,6 +491,18 @@ class EditOutputWidget : public QDialog
482491
a_bitrate_->setText(std::to_string((int)it->toDouble()).c_str());
483492
else
484493
a_bitrate_->setText("128");
494+
495+
it = conf_.find("a-mixer");
496+
{
497+
int dataToFind = 1;
498+
if (it != conf_.end() && it->isDouble())
499+
dataToFind = (int)it->toDouble();
500+
int index = a_mixer_->findData(dataToFind);
501+
if (index >= 0)
502+
a_mixer_->setCurrentIndex(index);
503+
else
504+
a_mixer_->setCurrentIndex(0);
505+
}
485506
}
486507
};
487508

@@ -593,6 +614,7 @@ class PushWidget : public QWidget, public IOBSOutputEventHanlder
593614

594615
std::string venc_id, aenc_id;
595616
int v_bitrate = 2000, a_bitrate = 128;
617+
int a_mixer = 0;
596618
int v_width = -1, v_height = -1;
597619
int v_keyframe_sec = 3;
598620

@@ -625,6 +647,13 @@ class PushWidget : public QWidget, public IOBSOutputEventHanlder
625647
it = conf_.find("v-keyframe-sec");
626648
if (it != conf_.end() && it->isDouble())
627649
v_keyframe_sec = (int)it->toDouble();
650+
it = conf_.find("a-mixer");
651+
if (it != conf_.end() && it->isDouble())
652+
{
653+
int data = (int)it->toDouble();
654+
if (data >= 0 && data <= 5)
655+
a_mixer = data;
656+
}
628657
}
629658

630659
// ====== prepare encoder
@@ -678,7 +707,7 @@ class PushWidget : public QWidget, public IOBSOutputEventHanlder
678707
{
679708
obs_data_t* settings = obs_data_create();
680709
obs_data_set_int(settings, "bitrate", a_bitrate);
681-
aenc = obs_audio_encoder_create(aenc_id.c_str(), "multi-rtmp-audio-encoder", settings, 0, nullptr);
710+
aenc = obs_audio_encoder_create(aenc_id.c_str(), "multi-rtmp-audio-encoder", settings, a_mixer, nullptr);
682711
obs_data_release(settings);
683712
obs_encoder_set_audio(aenc, obs_get_audio());
684713
}

0 commit comments

Comments
 (0)