Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

fix: framerate always set to 1 in windows #1

Open
wants to merge 1 commit into
base: senpai
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions nokhwa-bindings-windows/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,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(),
Expand Down Expand Up @@ -1032,8 +1039,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());
Expand Down