Fix encoder probing when no display is active

This commit is contained in:
Yukino Song
2025-05-31 15:04:06 +08:00
parent 34766201d2
commit 1ca19853c2
2 changed files with 21 additions and 7 deletions

View File

@@ -318,7 +318,7 @@ int main(int argc, char *argv[]) {
if (video::probe_encoders()) {
#ifdef _WIN32
// Create a temporary virtual display for encoder capability probing if no active display was found
if (!video::allow_encoder_probing() && proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
if (!video::allow_encoder_probing()) {
std::string probe_uuid_str = PROBE_DISPLAY_UUID;
auto probe_uuid = uuid_util::uuid_t::parse(probe_uuid_str);
auto* probe_guid = (GUID*)(void*)&probe_uuid;
@@ -340,15 +340,19 @@ int main(int argc, char *argv[]) {
// Probe again anyways
if (video::probe_encoders()) {
BOOST_LOG(error) << "Video failed to find working encoder"sv;
BOOST_LOG(error) << "Video failed to find working encoder even after attempted with a virtual display"sv;
}
VDISPLAY::removeVirtualDisplay(*probe_guid);
} else {
BOOST_LOG(error) << "Video failed to find working encoder"sv;
if (proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
BOOST_LOG(error) << "Video failed to find working encoder: allow probing but failed"sv;
} else {
BOOST_LOG(error) << "Video failed to find working encoder: probe failed and virtual display driver isn't initialized"sv;
}
}
#else
BOOST_LOG(error) << "Video failed to find working encoder"sv;
BOOST_LOG(error) << "Video failed to find working encoder: probing failed."sv;
#endif
}

View File

@@ -32,6 +32,7 @@ extern "C" {
#include "video.h"
#ifdef _WIN32
#include "platform/windows/virtual_display.h"
extern "C" {
#include <libavutil/hwcontext_d3d11va.h>
}
@@ -48,10 +49,19 @@ namespace video {
bool allow_encoder_probing() {
const auto devices {display_device::enumerate_devices()};
// If there are no devices, then either the API is not working correctly or OS does not support the lib.
// Either way we should not block the probing in this case as we can't tell what's wrong.
// // If there are no devices, then either the API is not working correctly or OS does not support the lib.
// // Either way we should not block the probing in this case as we can't tell what's wrong.
// if (devices.empty()) {
// return true;
// }
if (devices.empty()) {
return true;
// We'll create a temporary virtual display for probing anyways.
if (proc::vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK) {
return false;
} else {
return true;
}
}
// Since Windows 11 24H2, it is possible that there will be no active devices present