-
-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
Hi,
use image::ColorType;
use scap::{
capturer::{self, Capturer},
frame::convert_bgra_to_rgb,
};
use tokio::time::Instant;
#[tokio::main]
async fn main() {
println!("Hello, world!");
assert!(scap::is_supported());
assert!(scap::request_permission());
assert!(scap::has_permission());
let capturer_options = capturer::Options {
output_type: scap::frame::FrameType::RGB,
..Default::default()
};
let mut recorder = Capturer::build(capturer_options).unwrap();
recorder.start_capture();
let time = Instant::now();
std::io::stdin().read_line(&mut String::default()).unwrap();
recorder.stop_capture();
let record_time = time.elapsed();
println!("{:#?}", record_time);
let mut buf = vec![];
let mut width = 0;
let mut height = 0;
while let Ok(frame) = recorder.get_next_frame() {
match frame {
scap::frame::Frame::BGRx(bgrx_frame) => {
buf.push(convert_bgra_to_rgb(bgrx_frame.data));
width = bgrx_frame.width as u32;
height = bgrx_frame.height as u32;
}
_ => unreachable!("Where is my BGR"),
}
}
println!("Total Frame = {}", buf.len());
println!("FPS = {}", buf.len() as u64 / record_time.as_secs());
for (i, frame) in buf.iter().enumerate() {
let location = format!("frames/{}.png", i);
image::save_buffer(location, frame, width, height, ColorType::Rgb8).unwrap();
}
}
Even if I gave RGB output is always BGRx for me.
I'm using Hyprland
callmenoodles
Metadata
Metadata
Assignees
Labels
No labels