region capture overlay window

This commit is contained in:
2026-05-12 00:06:31 +03:00
parent 03af276a1d
commit 14d02cdad4
11 changed files with 305 additions and 14 deletions
+10 -1
View File
@@ -5,6 +5,8 @@ use anyhow::{anyhow, Result};
use windows_capture::capture::{
CaptureControl, Context as CaptureContext, GraphicsCaptureApiHandler,
};
use crate::CaptureRect;
use windows_capture::encoder::{
AudioSettingsBuilder, ContainerSettingsBuilder, VideoEncoder, VideoSettingsBuilder,
};
@@ -73,10 +75,16 @@ pub struct CaptureSession {
pub started_at: Instant,
pub width: u32,
pub height: u32,
pub crop: Option<CaptureRect>,
control: CaptureControl<CaptureHandler, anyhow::Error>,
}
pub fn start(output_path: PathBuf, capture_cursor: bool, audio: bool) -> Result<CaptureSession> {
pub fn start(
output_path: PathBuf,
capture_cursor: bool,
audio: bool,
crop: Option<CaptureRect>,
) -> Result<CaptureSession> {
let monitor = Monitor::primary().map_err(|e| anyhow!("primary monitor: {e:?}"))?;
let width = monitor
.width()
@@ -117,6 +125,7 @@ pub fn start(output_path: PathBuf, capture_cursor: bool, audio: bool) -> Result<
started_at: Instant::now(),
width,
height,
crop,
control,
})
}