Add video reset check

This commit is contained in:
Exeldro 2024-07-16 09:52:05 +02:00
parent 3d708f8c7b
commit ad33461aaa
No known key found for this signature in database
GPG Key ID: 97269A83FC715751
4 changed files with 39 additions and 11 deletions

View File

@ -971,7 +971,7 @@ void OBSBasicSettings::RefreshProperties(obs_properties_t *properties, QFormLayo
static bool obs_encoder_parent_video_loaded = false;
static video_t *(*obs_encoder_parent_video_wrapper)(const obs_encoder_t *encoder) = nullptr;
void OBSBasicSettings::LoadOutputStats()
void OBSBasicSettings::LoadOutputStats(std::vector<video_t *> *oldVideos)
{
if (!obs_encoder_parent_video_loaded) {
void *dl = os_dlopen("obs");
@ -1047,6 +1047,8 @@ void OBSBasicSettings::LoadOutputStats()
stats += "Vertical Canvas ";
} else if (video == obs_get_video()) {
stats += "Main Canvas ";
} else if (std::find(oldVideos->begin(), oldVideos->end(), video) != oldVideos->end()) {
stats += "Old Main Canvas ";
} else {
if (last_video != video) {
video_count++;
@ -1056,7 +1058,9 @@ void OBSBasicSettings::LoadOutputStats()
stats += std::to_string(video_count);
stats += " ";
}
if (encoder) {
if (video && std::find(oldVideos->begin(), oldVideos->end(), video) != oldVideos->end()) {
stats += obs_output_active(output) ? "Active " : "Inactive ";
} else if (encoder) {
stats += "(";
stats += std::to_string(obs_encoder_get_width(encoder));
stats += "x";
@ -1070,6 +1074,13 @@ void OBSBasicSettings::LoadOutputStats()
video_output_get_frame_rate(video) / obs_encoder_get_frame_rate_divisor(encoder), 2);
stats += "fps ";
stats += obs_encoder_active(encoder) ? "Active " : "Inactive ";
if (video) {
stats += "skipped frames ";
stats += std::to_string(video_output_get_skipped_frames(video));
stats += "/";
stats += std::to_string(video_output_get_total_frames(video));
stats += " ";
}
} else if (video) {
stats += "(";
stats += std::to_string(video_output_get_width(video));
@ -1079,6 +1090,11 @@ void OBSBasicSettings::LoadOutputStats()
stats += to_string_with_precision(video_output_get_frame_rate(video), 2);
stats += "fps ";
stats += video_output_active(video) ? "Active " : "Inactive ";
stats += "skipped frames ";
stats += std::to_string(video_output_get_skipped_frames(video));
stats += "/";
stats += std::to_string(video_output_get_total_frames(video));
stats += " ";
} else {
stats += "(";
stats += std::to_string(obs_output_get_width(output));
@ -1087,13 +1103,6 @@ void OBSBasicSettings::LoadOutputStats()
stats += ") ";
stats += obs_output_active(output) ? "Active " : "Inactive ";
}
if (video) {
stats += "skipped frames ";
stats += std::to_string(video_output_get_skipped_frames(video));
stats += "/";
stats += std::to_string(video_output_get_total_frames(video));
stats += " ";
}
stats += obs_output_get_name(output);
stats += "(";
stats += obs_output_get_id(output);

View File

@ -68,7 +68,7 @@ public:
void LoadSettings(obs_data_t *settings);
void LoadVerticalSettings();
void SaveVerticalSettings();
void LoadOutputStats();
void LoadOutputStats(std::vector<video_t *>* oldVideos);
void SetNewerVersion(QString newer_version_available);
public slots:
};

View File

@ -248,7 +248,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
obs_data_apply(settings, current_config);
configDialog->LoadSettings(settings);
configDialog->LoadVerticalSettings();
configDialog->LoadOutputStats();
configDialog->LoadOutputStats(&oldVideo);
configDialog->SetNewerVersion(newer_version_available);
configDialog->setResult(QDialog::Rejected);
if (configDialog->exec() == QDialog::Accepted) {
@ -281,6 +281,20 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
mainLayout->addLayout(buttonRow);
obs_frontend_add_event_callback(frontend_event, this);
mainVideo = obs_get_video();
connect(&videoCheckTimer, &QTimer::timeout, [this] {
if (obs_get_video() != mainVideo) {
oldVideo.push_back(mainVideo);
mainVideo = obs_get_video();
for (auto it = outputs.begin(); it != outputs.end(); it++) {
auto venc = obs_output_get_video_encoder(it->second);
if (venc && !obs_encoder_active(venc))
obs_encoder_set_video(venc, mainVideo);
}
}
});
videoCheckTimer.start(1000);
}
MultistreamDock::~MultistreamDock()

View File

@ -6,6 +6,7 @@
#include <QFrame>
#include <QPushButton>
#include <QVBoxLayout>
#include <QTimer>
class OBSBasicSettings;
@ -24,6 +25,10 @@ private:
QString newer_version_available;
QTimer videoCheckTimer;
video_t *mainVideo = nullptr;
std::vector<video_t *> oldVideo;
std::map<std::string, obs_output_t *> outputs;
void LoadSettingsFile();