From 2eca4b64b64c79edcc595248edc624ddb8edbbe7 Mon Sep 17 00:00:00 2001 From: lashman Date: Sat, 30 May 2026 00:43:10 +0300 Subject: [PATCH] fix GIF speed: remove capture-side fps filter, let encoder handle conversion The capture pipeline was applying fps=N to drop frames from monitor refresh rate to user fps. Then the GIF encoder applied fps=M on the already-converted file. Double fps conversion = broken frame timestamps = wrong playback speed. Fix: remove fps filter from capture. Intermediate files keep monitor's native refresh rate (e.g. 120fps). The GIF/video encoder's fps filter handles the conversion correctly in one clean step. Also removed redundant -r flag from GIF encoder (already done), and restored the 16:9 preset and low FPS options that were removed earlier. --- src-tauri/src/capture.rs | 5 ++++- src-tauri/src/encode.rs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/capture.rs b/src-tauri/src/capture.rs index 1006e1b..4f4abb5 100644 --- a/src-tauri/src/capture.rs +++ b/src-tauri/src/capture.rs @@ -58,7 +58,10 @@ impl GraphicsCaptureApiHandler for CaptureHandler { }; // Reduce frame rate before scaling to avoid processing unnecessary frames - filter_parts.push(format!("fps={}", setup.fps)); + // NOTE: Do NOT add fps filter here - it mangles timestamps and causes + // double fps conversion when the GIF/video encoder also applies fps filtering. + // The intermediate file keeps the monitor's native refresh rate. + // The export pipeline's fps filter handles the conversion correctly. if working_width > MAX_ENCODE_WIDTH { filter_parts.push(format!("scale={}:-2", MAX_ENCODE_WIDTH)); diff --git a/src-tauri/src/encode.rs b/src-tauri/src/encode.rs index 953e831..1617f5c 100644 --- a/src-tauri/src/encode.rs +++ b/src-tauri/src/encode.rs @@ -465,7 +465,7 @@ fn encode_gif_pass( }; // Single-pass approach: split the stream, generate palette from one copy, - // apply palette to the other. Uses -r for output framerate. + // apply palette to the other. The fps filter handles frame rate conversion. let filter_complex = format!( "{cprefix}{kprefix}fps={fps},{sprefix}scale={w}:-1:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff:max_colors={colors}[p];[s1][p]paletteuse=dither={d}", cprefix = crop_prefix,