fix(windows): validate WGC encoder fps

This commit is contained in:
wiiiii123
2026-05-22 17:13:43 +07:00
parent ed11c26983
commit 58e413fca4
3 changed files with 43 additions and 34 deletions
@@ -1,35 +1,35 @@
{
"version": 1,
"platform": "win32",
"arch": "x64",
"helpers": {
"wgc-capture": {
"binaryName": "wgc-capture.exe",
"binarySha256": "78a15935cad651c06ec64df3cabf8945a0d66e647e3eb97dfe75cd4c90d66564",
"sourceDir": "electron/native/wgc-capture",
"sourceFingerprint": "504f3447cf64455a5c7ab1831e4257aee483c5714e714d0e020427e4c491e5eb",
"updatedAt": "2026-05-22T10:06:11.293Z"
},
"cursor-monitor": {
"binaryName": "cursor-monitor.exe",
"binarySha256": "6ae6d91103b6e891a851e8ea5791e1c1f9aaab700134c18bc4c46cfffd7fdd12",
"sourceDir": "electron/native/cursor-monitor",
"sourceFingerprint": "6ad1b8b50bb336f2a48937b06f5ec56d90b6ab4a3e56a4bca278cf67a5d3e52e",
"updatedAt": "2026-05-07T15:22:18.173Z"
},
"recordly-gpu-export": {
"binaryName": "recordly-gpu-export.exe",
"binarySha256": "4cb3a293fd36f718af55906820d9b3fd78babc855888c2e248f0b918ec1aff3c",
"sourceDir": "electron/native/gpu-export-probe",
"sourceFingerprint": "743b386a5f1bbcc99cec5465c3de228d2b045061dead31dfcbf25cf6a1e61de5",
"updatedAt": "2026-05-07T20:13:48.585Z"
},
"recordly-nvidia-cuda-compositor": {
"binaryName": "recordly-nvidia-cuda-compositor.exe",
"binarySha256": "a787531c07142de7c292d1726e0339c97dbce5073d9a0853d539a725265fd945",
"sourceDir": "electron/native/nvidia-cuda-compositor",
"sourceFingerprint": "528b599e9d576d81ec087d0d4dc93a79af1bbf30fdb969f44f773bef90146135",
"updatedAt": "2026-05-07T20:14:13.794Z"
}
}
"version": 1,
"platform": "win32",
"arch": "x64",
"helpers": {
"wgc-capture": {
"binaryName": "wgc-capture.exe",
"binarySha256": "b840fb2847ac8fcfc5137febfc8dd49b55a4d15bea4f9185a0916fb0c1544bed",
"sourceDir": "electron/native/wgc-capture",
"sourceFingerprint": "fdbc8002a894a1300c7fed58a0f7aae18119dbb2bd71bcaacf3bfc398db904a9",
"updatedAt": "2026-05-22T10:12:36.734Z"
},
"cursor-monitor": {
"binaryName": "cursor-monitor.exe",
"binarySha256": "6ae6d91103b6e891a851e8ea5791e1c1f9aaab700134c18bc4c46cfffd7fdd12",
"sourceDir": "electron/native/cursor-monitor",
"sourceFingerprint": "6ad1b8b50bb336f2a48937b06f5ec56d90b6ab4a3e56a4bca278cf67a5d3e52e",
"updatedAt": "2026-05-07T15:22:18.173Z"
},
"recordly-gpu-export": {
"binaryName": "recordly-gpu-export.exe",
"binarySha256": "4cb3a293fd36f718af55906820d9b3fd78babc855888c2e248f0b918ec1aff3c",
"sourceDir": "electron/native/gpu-export-probe",
"sourceFingerprint": "743b386a5f1bbcc99cec5465c3de228d2b045061dead31dfcbf25cf6a1e61de5",
"updatedAt": "2026-05-07T20:13:48.585Z"
},
"recordly-nvidia-cuda-compositor": {
"binaryName": "recordly-nvidia-cuda-compositor.exe",
"binarySha256": "a787531c07142de7c292d1726e0339c97dbce5073d9a0853d539a725265fd945",
"sourceDir": "electron/native/nvidia-cuda-compositor",
"sourceFingerprint": "528b599e9d576d81ec087d0d4dc93a79af1bbf30fdb969f44f773bef90146135",
"updatedAt": "2026-05-07T20:14:13.794Z"
}
}
}
Binary file not shown.
+10 -1
View File
@@ -27,6 +27,11 @@ bool MFEncoder::initialize(const std::wstring& outputPath, int width, int height
if (initialized_) return false;
if (fps <= 0) {
std::cerr << "ERROR: Encoder fps must be positive, got " << fps << std::endl;
return false;
}
if (width % 2 != 0 || height % 2 != 0) {
std::cerr << "ERROR: Encoder dimensions must be even, got " << width << "x" << height << std::endl;
return false;
@@ -273,6 +278,10 @@ bool MFEncoder::extendLastFrameToLocked(int64_t timestampHns) {
bool MFEncoder::writeNv12SampleLocked(const std::vector<uint8_t>& frameBuffer, int64_t timestampHns) {
if (frameBuffer.empty()) return false;
if (fps_ <= 0) return false;
const int64_t frameDurationHns = 10000000LL / fps_;
if (frameDurationHns <= 0) return false;
// Create MF sample
DWORD bufferSize = static_cast<DWORD>(frameBuffer.size());
@@ -294,7 +303,7 @@ bool MFEncoder::writeNv12SampleLocked(const std::vector<uint8_t>& frameBuffer, i
sample->AddBuffer(buffer.Get());
sample->SetSampleTime(timestampHns);
sample->SetSampleDuration(10000000LL / fps_);
sample->SetSampleDuration(frameDurationHns);
hr = sinkWriter_->WriteSample(streamIndex_, sample.Get());
if (FAILED(hr)) {