Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(recording): ask the webcam reader for the selected mode's frame rate

EtienneLescot1a0b369f8b19
diff --git a/electron/native/wgc-capture/src/webcam_capture.cpp b/electron/native/wgc-capture/src/webcam_capture.cpp
index a876c956a..d6f3920c7 100644
--- a/electron/native/wgc-capture/src/webcam_capture.cpp
+++ b/electron/native/wgc-capture/src/webcam_capture.cpp
@@ -438,8 +438,14 @@ bool WebcamCapture::configureReader(
MF_MT_FRAME_SIZE,
static_cast<UINT32>(chosen.width),
static_cast<UINT32>(chosen.height));
+ // The selected mode's own rate: asking 30 of a 24 fps mode is
+ // accepted, and the reader then reports 30 -- a rate the
+ // camera does not have.
MFSetAttributeRatio(
- outputType.Get(), MF_MT_FRAME_RATE, static_cast<UINT32>(std::max(1, requestedFps)), 1);
+ outputType.Get(),
+ MF_MT_FRAME_RATE,
+ static_cast<UINT32>(chosen.fps > 0 ? chosen.fps : std::max(1, requestedFps)),
+ 1);
}
if (SUCCEEDED(sourceReader_->SetCurrentMediaType(
MF_SOURCE_READER_FIRST_VIDEO_STREAM, nullptr, outputType.Get()))) {