configurable capture fps
This commit is contained in:
@@ -17,7 +17,6 @@ use windows_capture::settings::{
|
|||||||
|
|
||||||
use crate::CaptureRect;
|
use crate::CaptureRect;
|
||||||
|
|
||||||
const TARGET_FPS: u32 = 30;
|
|
||||||
const MAX_ENCODE_WIDTH: u32 = 1920;
|
const MAX_ENCODE_WIDTH: u32 = 1920;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -149,6 +148,7 @@ pub fn start(
|
|||||||
capture_cursor: bool,
|
capture_cursor: bool,
|
||||||
_audio: bool,
|
_audio: bool,
|
||||||
crop: Option<CaptureRect>,
|
crop: Option<CaptureRect>,
|
||||||
|
fps: u32,
|
||||||
) -> Result<CaptureSession> {
|
) -> Result<CaptureSession> {
|
||||||
let monitor = Monitor::primary().map_err(|e| anyhow!("primary monitor: {e:?}"))?;
|
let monitor = Monitor::primary().map_err(|e| anyhow!("primary monitor: {e:?}"))?;
|
||||||
let raw_width = monitor
|
let raw_width = monitor
|
||||||
@@ -167,7 +167,7 @@ pub fn start(
|
|||||||
ffmpeg_path,
|
ffmpeg_path,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
fps: TARGET_FPS,
|
fps,
|
||||||
crop,
|
crop,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ fn start_capture(
|
|||||||
cfg.capture.capture_cursor,
|
cfg.capture.capture_cursor,
|
||||||
cfg.capture.capture_audio,
|
cfg.capture.capture_audio,
|
||||||
crop,
|
crop,
|
||||||
|
cfg.capture.default_fps,
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("{e:#}"))?;
|
.map_err(|e| format!("{e:#}"))?;
|
||||||
|
|
||||||
@@ -347,12 +348,13 @@ fn resume_capture(state: State<'_, AppState>) -> Result<(), String> {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let fps = state.config.lock().expect("config mutex").capture.default_fps;
|
||||||
let output = segment_path(&state.app_dir, next_idx);
|
let output = segment_path(&state.app_dir, next_idx);
|
||||||
let ffmpeg = bootstrap::ffmpeg_path(&state.app_dir);
|
let ffmpeg = bootstrap::ffmpeg_path(&state.app_dir);
|
||||||
if !ffmpeg.is_file() {
|
if !ffmpeg.is_file() {
|
||||||
return Err("ffmpeg.exe not found".to_string());
|
return Err("ffmpeg.exe not found".to_string());
|
||||||
}
|
}
|
||||||
let session = capture::start(output, ffmpeg, capture_cursor, audio, crop)
|
let session = capture::start(output, ffmpeg, capture_cursor, audio, crop, fps)
|
||||||
.map_err(|e| format!("{e:#}"))?;
|
.map_err(|e| format!("{e:#}"))?;
|
||||||
*state.capture.lock().expect("capture mutex") = Some(session);
|
*state.capture.lock().expect("capture mutex") = Some(session);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user