Skip to content

Commit

Permalink
Enable frame rate divisor and scale for vertical
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Nov 26, 2024
1 parent 75a528c commit b939fa6
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 85 deletions.
155 changes: 77 additions & 78 deletions config-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,96 +644,95 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
videoEncoderGroup->setLayout(videoEncoderGroupLayout);
videoPageLayout->addRow(videoEncoderGroup);

if (main) {
struct obs_video_info ovi;
obs_get_video_info(&ovi);
double fps = ovi.fps_den > 0 ? (double)ovi.fps_num / (double)ovi.fps_den : 0.0;
auto fpsDivisor = new QComboBox;
auto frd = obs_data_get_int(settings, "frame_rate_divisor");
for (int i = 1; i <= 10; i++) {
if (i == 1) {
fpsDivisor->addItem(
QString::number(fps, 'g', 3) + " " + QString::fromUtf8(obs_module_text("Original")), i);
fpsDivisor->setCurrentIndex(0);
} else {
fpsDivisor->addItem(QString::number(fps / i, 'g', 3), i);
if (frd == i) {
fpsDivisor->setCurrentIndex(fpsDivisor->count() - 1);
}
struct obs_video_info ovi;
obs_get_video_info(&ovi);
double fps = ovi.fps_den > 0 ? (double)ovi.fps_num / (double)ovi.fps_den : 0.0;
auto fpsDivisor = new QComboBox;
auto frd = obs_data_get_int(settings, "frame_rate_divisor");
for (int i = 1; i <= 10; i++) {
if (i == 1) {
fpsDivisor->addItem(QString::number(fps, 'g', 3) + " " + QString::fromUtf8(obs_module_text("Original")), i);
fpsDivisor->setCurrentIndex(0);
} else {
fpsDivisor->addItem(QString::number(fps / i, 'g', 3), i);
if (frd == i) {
fpsDivisor->setCurrentIndex(fpsDivisor->count() - 1);
}
}
}
connect(fpsDivisor, &QComboBox::currentIndexChanged, [fpsDivisor, settings] {
obs_data_set_int(settings, "frame_rate_divisor", fpsDivisor->currentData().toInt());
});

videoEncoderGroupLayout->addRow(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.FPS")),
fpsDivisor);
//obs_encoder_get_frame_rate_divisor
videoEncoderGroupLayout->addRow(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.FPS")), fpsDivisor);
//obs_encoder_get_frame_rate_divisor

auto scale = new QGroupBox(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Output.Adv.Rescale")));
scale->setCheckable(true);
scale->setChecked(obs_data_get_bool(settings, "scale"));
auto scale = new QGroupBox(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Output.Adv.Rescale")));
scale->setCheckable(true);
scale->setChecked(obs_data_get_bool(settings, "scale"));

connect(scale, &QGroupBox::toggled,
[scale, settings] { obs_data_set_bool(settings, "scale", scale->isChecked()); });
connect(scale, &QGroupBox::toggled, [scale, settings] { obs_data_set_bool(settings, "scale", scale->isChecked()); });

auto scaleLayout = new QFormLayout();
scale->setLayout(scaleLayout);
auto scaleLayout = new QFormLayout();
scale->setLayout(scaleLayout);

auto downscale = new QComboBox;
auto downscale = new QComboBox;

auto downscale_type = obs_data_get_int(settings, "scale_type");
if (downscale_type == OBS_SCALE_DISABLE) {
downscale_type = OBS_SCALE_BILINEAR;
obs_data_set_int(settings, "scale_type", downscale_type);
}
downscale->addItem(
QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Bilinear")),
OBS_SCALE_BILINEAR);
if (downscale_type == OBS_SCALE_BILINEAR)
downscale->setCurrentIndex(0);
downscale->addItem(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Area")),
OBS_SCALE_AREA);
if (downscale_type == OBS_SCALE_AREA)
downscale->setCurrentIndex(1);
downscale->addItem(
QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Bicubic")),
OBS_SCALE_BICUBIC);
if (downscale_type == OBS_SCALE_BICUBIC)
downscale->setCurrentIndex(2);
downscale->addItem(
QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Lanczos")),
OBS_SCALE_LANCZOS);
if (downscale_type == OBS_SCALE_LANCZOS)
downscale->setCurrentIndex(3);

connect(downscale, &QComboBox::currentIndexChanged,
[downscale, settings] { obs_data_set_int(settings, "scale_type", downscale->currentData().toInt()); });

scaleLayout->addRow(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter")),
downscale);

auto resolution = new QComboBox;
resolution->setEditable(true);
auto downscale_type = obs_data_get_int(settings, "scale_type");
if (downscale_type == OBS_SCALE_DISABLE) {
downscale_type = OBS_SCALE_BILINEAR;
obs_data_set_int(settings, "scale_type", downscale_type);
}
downscale->addItem(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Bilinear")),
OBS_SCALE_BILINEAR);
if (downscale_type == OBS_SCALE_BILINEAR)
downscale->setCurrentIndex(0);
downscale->addItem(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Area")),
OBS_SCALE_AREA);
if (downscale_type == OBS_SCALE_AREA)
downscale->setCurrentIndex(1);
downscale->addItem(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Bicubic")),
OBS_SCALE_BICUBIC);
if (downscale_type == OBS_SCALE_BICUBIC)
downscale->setCurrentIndex(2);
downscale->addItem(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter.Lanczos")),
OBS_SCALE_LANCZOS);
if (downscale_type == OBS_SCALE_LANCZOS)
downscale->setCurrentIndex(3);

connect(downscale, &QComboBox::currentIndexChanged,
[downscale, settings] { obs_data_set_int(settings, "scale_type", downscale->currentData().toInt()); });

scaleLayout->addRow(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.DownscaleFilter")), downscale);

auto resolution = new QComboBox;
resolution->setEditable(true);
if (main) {
resolution->addItem("1280x720");
resolution->addItem("1920x1080");
resolution->addItem("2560x1440");
resolution->setCurrentText(QString::number(obs_data_get_int(settings, "width")) + "x" +
QString::number(obs_data_get_int(settings, "height")));
if (resolution->currentText() == "0x0")
resolution->setCurrentText(QString::number(ovi.output_width) + "x" + QString::number(ovi.output_height));

connect(resolution, &QComboBox::currentTextChanged, [settings, resolution] {
const auto res = resolution->currentText();
uint32_t width, height;
if (sscanf(res.toUtf8().constData(), "%dx%d", &width, &height) == 2 && width > 0 && height > 0) {
obs_data_set_int(settings, "width", width);
obs_data_set_int(settings, "height", height);
}
});
} else {
resolution->addItem("720x1280");
resolution->addItem("1080x1920");
resolution->addItem("1440x2560");
}
resolution->setCurrentText(QString::number(obs_data_get_int(settings, "width")) + "x" +
QString::number(obs_data_get_int(settings, "height")));
if (resolution->currentText() == "0x0")
resolution->setCurrentText(QString::number(ovi.output_width) + "x" + QString::number(ovi.output_height));

connect(resolution, &QComboBox::currentTextChanged, [settings, resolution] {
const auto res = resolution->currentText();
uint32_t width, height;
if (sscanf(res.toUtf8().constData(), "%dx%d", &width, &height) == 2 && width > 0 && height > 0) {
obs_data_set_int(settings, "width", width);
obs_data_set_int(settings, "height", height);
}
});

scaleLayout->addRow(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.ScaledResolution")),
resolution);
scaleLayout->addRow(QString::fromUtf8(obs_frontend_get_locale_string("Basic.Settings.Video.ScaledResolution")), resolution);

videoEncoderGroupLayout->addRow(scale);
}
videoEncoderGroupLayout->addRow(scale);

connect(videoEncoder, &QComboBox::currentIndexChanged,
[this, serverGroup, advancedGroupLayout, videoPageLayout, videoEncoder, videoEncoderIndex, videoEncoderGroup,
Expand Down Expand Up @@ -763,7 +762,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
obs_properties_destroy(t->second);
video_encoder_properties.erase(t);
}
for (int i = videoEncoderGroupLayout->rowCount() - 1; i >= (main ? 2 : 0); i--) {
for (int i = videoEncoderGroupLayout->rowCount() - 1; i >= 2; i--) {
videoEncoderGroupLayout->removeRow(i);
}
auto ves = encoder_changed ? nullptr : obs_data_get_obj(settings, "video_encoder_settings");
Expand Down
13 changes: 6 additions & 7 deletions multistream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ bool version_info_downloaded(void *param, struct file_download_data *file)
obs_data_release(d);
if (!data)
return true;
auto version = QString::fromUtf8(obs_data_get_string(data, "version"));
QStringList pieces = version.split(".");
if (pieces.count() > 2) {
auto major = pieces[0].toInt();
auto minor = pieces[1].toInt();
auto patch = pieces[2].toInt();
auto version = obs_data_get_string(data, "version");
int major;
int minor;
int patch;
if (sscanf(version, "%d.%d.%d", &major, &minor, &patch) == 3) {
auto sv = MAKE_SEMANTIC_VERSION(major, minor, patch);
if (sv > MAKE_SEMANTIC_VERSION(PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH)) {
QMetaObject::invokeMethod(multistream_dock, "NewerVersionAvailable", Q_ARG(QString, version));
QMetaObject::invokeMethod(multistream_dock, "NewerVersionAvailable", Q_ARG(QString, QString::fromUtf8(version)));
}
}
obs_data_release(data);
Expand Down

0 comments on commit b939fa6

Please sign in to comment.