From 4f42ccd9b818ccd85aea227ed1517020d17ef841 Mon Sep 17 00:00:00 2001 From: Giovanni Minotti Date: Sat, 14 Oct 2023 09:55:31 +0200 Subject: [PATCH] Fixed Windows framerate parsing --- nokhwa-bindings-windows/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nokhwa-bindings-windows/src/lib.rs b/nokhwa-bindings-windows/src/lib.rs index 73f9d34..0adf9ed 100644 --- a/nokhwa-bindings-windows/src/lib.rs +++ b/nokhwa-bindings-windows/src/lib.rs @@ -966,7 +966,14 @@ pub mod wmf { }; let frame_rate = match unsafe { media_type.GetUINT64(&MF_MT_FRAME_RATE) } { - Ok(fps) => fps as u32, + Ok(fps) => { + let mut numerator = (fps >> 32) as u32; + let denominator = fps as u32; + if denominator != 1 { + numerator = 0; + } + numerator + }, Err(why) => { return Err(NokhwaError::GetPropertyError { property: "MF_MT_FRAME_RATE".to_string(), @@ -1027,8 +1034,8 @@ pub mod wmf { let fps = { let frame_rate_u64 = 0_u64; let mut bytes: [u8; 8] = frame_rate_u64.to_le_bytes(); - bytes[7] = format.frame_rate() as u8; - bytes[3] = 0x01; + bytes[4] = format.frame_rate() as u8; + bytes[0] = 0x01; u64::from_le_bytes(bytes) }; let fourcc = frameformat_to_guid(format.format());