Skip to content

Commit

Permalink
Fixed Windows framerate parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Giotino committed Oct 14, 2023
1 parent ae0d818 commit 4f42ccd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nokhwa-bindings-windows/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 4f42ccd

Please sign in to comment.