From 67c2a841786b710793284cb253bf9f5f19ab5467 Mon Sep 17 00:00:00 2001 From: lashman Date: Sat, 30 May 2026 01:05:29 +0300 Subject: [PATCH] fix capture speeding up: remove framerate declaration and fps filter The capture was declaring -framerate 120 (monitor refresh rate) but the Windows capture API doesn't deliver frames at that rate. This caused ffmpeg to compress the timeline - 10 seconds of recording became 4 seconds of video. Fix: remove both -framerate and fps filter from capture. All frames are captured as they arrive. The export pipeline's fps filter handles rate conversion correctly. --- src-tauri/src/capture.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/capture.rs b/src-tauri/src/capture.rs index 1006e1b..92d38b4 100644 --- a/src-tauri/src/capture.rs +++ b/src-tauri/src/capture.rs @@ -26,6 +26,7 @@ pub struct CaptureSetup { pub ffmpeg_path: PathBuf, pub width: u32, pub height: u32, + #[allow(dead_code)] pub fps: u32, pub crop: Option, } @@ -57,8 +58,8 @@ impl GraphicsCaptureApiHandler for CaptureHandler { setup.width }; - // Reduce frame rate before scaling to avoid processing unnecessary frames - filter_parts.push(format!("fps={}", setup.fps)); + // Capture all frames at the rate they arrive. No fps filter in capture - + // the export pipeline handles frame rate conversion. if working_width > MAX_ENCODE_WIDTH { filter_parts.push(format!("scale={}:-2", MAX_ENCODE_WIDTH)); @@ -70,8 +71,7 @@ impl GraphicsCaptureApiHandler for CaptureHandler { // The capture API delivers frames at the monitor's refresh rate, not the // user's chosen FPS. We must tell ffmpeg the actual rate so timestamps are // correct. The fps filter in the export pipeline handles the conversion. - let capture_fps = detect_monitor_refresh_rate().max(setup.fps); - tracing::info!("capture: ffmpeg framerate={}, size={}x{}", capture_fps, setup.width, setup.height); + tracing::info!("capture: no declared framerate, size={}x{}", setup.width, setup.height); let mut cmd = Command::new(&setup.ffmpeg_path); cmd.arg("-y") @@ -80,7 +80,6 @@ impl GraphicsCaptureApiHandler for CaptureHandler { .args(["-f", "rawvideo"]) .args(["-pixel_format", "bgra"]) .args(["-video_size", &format!("{}x{}", setup.width, setup.height)]) - .args(["-framerate", &capture_fps.to_string()]) .args(["-i", "-"]) .args(["-vf", &filter]) .args(["-c:v", "libx264"]) @@ -176,6 +175,7 @@ pub fn primary_monitor_dims() -> Result<(u32, u32)> { Ok((w & !1, h & !1)) } +#[allow(dead_code)] /// Detect the primary monitor's refresh rate in Hz. /// Falls back to 60 if detection fails. fn detect_monitor_refresh_rate() -> u32 {