track frame count directly in capture handler, use for fps correction
The frame count is now tracked via Arc<AtomicU64> in the capture handler, incremented on each frame arrival. fix_intermediate_fps uses this count along with elapsed time to calculate the actual delivery rate, then re-encodes the intermediate with correct fps via stream copy.
This commit is contained in:
@@ -432,10 +432,11 @@ 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 frames = session.frame_counter.load(std::sync::atomic::Ordering::Relaxed);
|
||||
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)
|
||||
capture::fix_intermediate_fps(&ffmpeg, &raw_path, &fixed_path, elapsed, frames)
|
||||
.map_err(|e| format!("fixing fps: {e:#}"))?;
|
||||
let path = if fixed_path.exists() { fixed_path } else { raw_path };
|
||||
|
||||
@@ -519,10 +520,11 @@ 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 frames = session.frame_counter.load(std::sync::atomic::Ordering::Relaxed);
|
||||
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)
|
||||
capture::fix_intermediate_fps(&ffmpeg, &raw_path, &fixed_path, elapsed, frames)
|
||||
.map_err(|e| format!("fixing fps: {e:#}"))?;
|
||||
let final_path = if fixed_path.exists() { fixed_path } else { raw_path };
|
||||
ss.segments.push(final_path);
|
||||
|
||||
Reference in New Issue
Block a user