fix capture timing and gif size cap

- capture declares -framerate 999 to accept all frames without dropping
- after capture stops, measure actual delivery rate from frame count / elapsed time
- re-encode intermediate file with correct fps via stream copy (no quality loss)
- same fix applied to pause_capture segments
- gif: remove 15% size tolerance - never exceed target size
This commit is contained in:
2026-05-30 01:14:51 +03:00
parent 67c2a84178
commit 5d312b6b00
3 changed files with 90 additions and 17 deletions
+13 -3
View File
@@ -432,7 +432,12 @@ fn pause_capture(state: State<'_, AppState>) -> Result<(), String> {
.take()
.ok_or_else(|| "no capture in progress".to_string())?;
let elapsed = session.started_at.elapsed().as_secs_f64();
let path = session.stop().map_err(|e| format!("{e:#}"))?;
let raw_path = session.stop().map_err(|e| format!("{e:#}"))?;
let ffmpeg = bootstrap::ffmpeg_path(&state.app_dir);
let fixed_path = raw_path.with_extension("fixed.mp4");
capture::fix_intermediate_fps(&ffmpeg, &raw_path, &fixed_path, elapsed)
.map_err(|e| format!("fixing fps: {e:#}"))?;
let path = if fixed_path.exists() { fixed_path } else { raw_path };
let audio_path = lock(&state.audio)
.take()
@@ -514,8 +519,13 @@ fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedCl
let live = lock(&state.capture).take();
if let Some(session) = live {
let elapsed = session.started_at.elapsed().as_secs_f64();
let path = session.stop().map_err(|e| format!("{e:#}"))?;
ss.segments.push(path);
let raw_path = session.stop().map_err(|e| format!("{e:#}"))?;
let ffmpeg = bootstrap::ffmpeg_path(&state.app_dir);
let fixed_path = raw_path.with_extension("fixed.mp4");
capture::fix_intermediate_fps(&ffmpeg, &raw_path, &fixed_path, elapsed)
.map_err(|e| format!("fixing fps: {e:#}"))?;
let final_path = if fixed_path.exists() { fixed_path } else { raw_path };
ss.segments.push(final_path);
ss.total_recorded_secs += elapsed;
}