-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: windows 支持屏幕录制 * fix: 修复不支持平台提示 * chore: 更新文档 --------- Co-authored-by: nashaofu <[email protected]>
- Loading branch information
Showing
21 changed files
with
558 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use fs_extra::dir; | ||
use std::{ | ||
thread, | ||
time::{Duration, Instant}, | ||
}; | ||
use xcap::Monitor; | ||
|
||
fn main() { | ||
let monitors = Monitor::all().unwrap(); | ||
|
||
dir::create_all("target/monitors", true).unwrap(); | ||
|
||
let monitor = monitors.get(0).unwrap().clone(); | ||
|
||
let mut i = 0; | ||
let frame = 20; | ||
let start = Instant::now(); | ||
let fps = 1000 / frame; | ||
|
||
loop { | ||
i += 1; | ||
let time = Instant::now(); | ||
let image = monitor.capture_image().unwrap(); | ||
image | ||
.save(format!("target/monitors/monitor-{}.png", i,)) | ||
.unwrap(); | ||
let sleep_time = fps * i - start.elapsed().as_millis() as i128; | ||
println!( | ||
"sleep_time: {:?} current_step_time: {:?}", | ||
sleep_time, | ||
time.elapsed() | ||
); | ||
if sleep_time > 0 { | ||
thread::sleep(Duration::from_millis(sleep_time as u64)); | ||
} | ||
|
||
if i >= 900 { | ||
break; | ||
} | ||
} | ||
|
||
println!("time {:?}", start.elapsed()); | ||
let actual_fps = 900 / start.elapsed().as_secs(); | ||
println!("actual fps: {}", actual_fps); | ||
|
||
// ffmpeg -framerate {actual_fps} -i monitor-%d.png -c:v libx264 -pix_fmt yuv420p output.mp4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::{sync::Arc, thread, time::Duration}; | ||
use xcap::Monitor; | ||
|
||
fn main() { | ||
let monitor = Monitor::from_point(100, 100).unwrap(); | ||
|
||
let video_recorder = Arc::new(monitor.video_recorder().unwrap()); | ||
|
||
let video_recorder_clone = video_recorder.clone(); | ||
thread::spawn(move || { | ||
video_recorder_clone | ||
.on_frame(|frame| { | ||
println!("frame: {:?}", frame.width); | ||
Ok(()) | ||
}) | ||
.unwrap(); | ||
}); | ||
|
||
println!("start"); | ||
video_recorder.start().unwrap(); | ||
thread::sleep(Duration::from_secs(2)); | ||
println!("stop"); | ||
video_recorder.stop().unwrap(); | ||
thread::sleep(Duration::from_secs(2)); | ||
println!("start"); | ||
video_recorder.start().unwrap(); | ||
thread::sleep(Duration::from_secs(2)); | ||
println!("stop"); | ||
video_recorder.stop().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![allow(unused)] | ||
|
||
use crate::{video_recorder::Frame, XCapResult}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ImplVideoRecorder {} | ||
|
||
impl ImplVideoRecorder { | ||
pub fn new() -> XCapResult<Self> { | ||
unimplemented!() | ||
} | ||
|
||
pub fn on_frame<F>(&self, on_frame: F) -> XCapResult<()> | ||
where | ||
F: Fn(Frame) -> XCapResult<()> + Send + 'static, | ||
{ | ||
unimplemented!() | ||
} | ||
pub fn start(&self) -> XCapResult<()> { | ||
unimplemented!() | ||
} | ||
pub fn stop(&self) -> XCapResult<()> { | ||
unimplemented!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ mod wayland_capture; | |
mod xorg_capture; | ||
|
||
pub mod impl_monitor; | ||
pub mod impl_video_recorder; | ||
pub mod impl_window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.