mirror of
https://github.com/Aitum/obs-aitum-multistream.git
synced 2024-11-25 03:33:28 +01:00
Cache video encoder descriptions
This commit is contained in:
parent
95c3b886b9
commit
25140bfd29
@ -559,9 +559,18 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
|
||||
videoEncoder->setCurrentIndex(0);
|
||||
videoPageLayout->addRow(QString::fromUtf8(obs_module_text("VideoEncoder")), videoEncoder);
|
||||
|
||||
bool allEmpty = false;
|
||||
auto videoEncoderIndex = new QComboBox;
|
||||
for (int i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) {
|
||||
videoEncoderIndex->addItem(QString::number(i + 1) + " " + mainEncoderDescriptions[i]);
|
||||
QString settingName = QString::fromUtf8("video_encoder_description") + QString::number(i);
|
||||
auto description = obs_data_get_string(this->settings, settingName.toUtf8().constData());
|
||||
if (!description || description[0] == '\0') {
|
||||
if (i != 0 && !allEmpty) {
|
||||
break;
|
||||
}
|
||||
allEmpty = true;
|
||||
}
|
||||
videoEncoderIndex->addItem(QString::number(i + 1) + " " + description);
|
||||
}
|
||||
videoEncoderIndex->setCurrentIndex(obs_data_get_int(settings, "video_encoder_index"));
|
||||
connect(videoEncoderIndex, &QComboBox::currentIndexChanged, [videoEncoderIndex, settings] {
|
||||
@ -733,7 +742,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
|
||||
if (strcmp(type, current_type) == 0)
|
||||
videoEncoder->setCurrentIndex(videoEncoder->count() - 1);
|
||||
}
|
||||
if (!advanced || videoEncoder->currentIndex() <= 0)
|
||||
if (videoEncoder->currentIndex() <= 0)
|
||||
videoEncoderGroup->setVisible(false);
|
||||
|
||||
auto audioEncoder = new QComboBox;
|
||||
|
@ -80,7 +80,5 @@ public:
|
||||
void LoadOutputStats(std::vector<video_t *> *oldVideos);
|
||||
void SetNewerVersion(QString newer_version_available);
|
||||
|
||||
QStringList mainEncoderDescriptions = QStringList(MAX_OUTPUT_VIDEO_ENCODERS);
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
@ -284,7 +284,6 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
||||
QPushButton::connect(configButton, &QPushButton::clicked, [this] {
|
||||
if (!configDialog)
|
||||
configDialog = new OBSBasicSettings((QMainWindow *)obs_frontend_get_main_window());
|
||||
configDialog->mainEncoderDescriptions = mainEncoderDescriptions;
|
||||
auto settings = obs_data_create();
|
||||
if (current_config)
|
||||
obs_data_apply(settings, current_config);
|
||||
@ -929,6 +928,8 @@ void MultistreamDock::LoadVerticalOutputs(bool firstLoad)
|
||||
|
||||
void MultistreamDock::storeMainStreamEncoders()
|
||||
{
|
||||
if (!current_config)
|
||||
return;
|
||||
struct obs_video_info ovi = {0};
|
||||
obs_get_video_info(&ovi);
|
||||
double fps = ovi.fps_den > 0 ? (double)ovi.fps_num / (double)ovi.fps_den : 0.0;
|
||||
@ -936,24 +937,28 @@ void MultistreamDock::storeMainStreamEncoders()
|
||||
bool found = false;
|
||||
for (auto i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) {
|
||||
auto encoder = obs_output_get_video_encoder2(output, i);
|
||||
QString settingName = QString::fromUtf8("video_encoder_description") + QString::number(i);
|
||||
if (encoder) {
|
||||
found = true;
|
||||
mainEncoderDescriptions[i] = QString::number(obs_encoder_get_width(encoder)) + "x" +
|
||||
auto mainEncoderDescription = QString::number(obs_encoder_get_width(encoder)) + "x" +
|
||||
QString::number(obs_encoder_get_height(encoder));
|
||||
auto divisor = obs_encoder_get_frame_rate_divisor(encoder);
|
||||
if (divisor > 0)
|
||||
mainEncoderDescriptions[i] +=
|
||||
mainEncoderDescription +=
|
||||
QString::fromUtf8(" ") + QString::number(fps / divisor, 'g', 4) + QString::fromUtf8("fps");
|
||||
|
||||
auto settings = obs_encoder_get_settings(encoder);
|
||||
auto bitrate = settings ? obs_data_get_int(settings, "bitrate") : 0;
|
||||
if (bitrate > 0)
|
||||
mainEncoderDescriptions[i] +=
|
||||
mainEncoderDescription +=
|
||||
QString::fromUtf8(" ") + QString::number(bitrate) + QString::fromUtf8("Kbps");
|
||||
obs_data_release(settings);
|
||||
|
||||
} else if (found && !mainEncoderDescriptions[i].isEmpty()) {
|
||||
mainEncoderDescriptions[i] = "";
|
||||
obs_data_set_string(current_config, settingName.toUtf8().constData(),
|
||||
mainEncoderDescription.toUtf8().constData());
|
||||
|
||||
} else if (found && obs_data_has_user_value(current_config, settingName.toUtf8().constData())) {
|
||||
obs_data_unset_user_value(current_config, settingName.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
obs_output_release(output);
|
||||
|
@ -46,7 +46,6 @@ private:
|
||||
void outputButtonStyle(QPushButton *button);
|
||||
|
||||
void storeMainStreamEncoders();
|
||||
QStringList mainEncoderDescriptions = QStringList(MAX_OUTPUT_VIDEO_ENCODERS);
|
||||
|
||||
QIcon streamActiveIcon = QIcon(":/aitum/media/streaming.svg");
|
||||
QIcon streamInactiveIcon = QIcon(":/aitum/media/stream.svg");
|
||||
|
Loading…
Reference in New Issue
Block a user