fix batch: missing cancel_export, overlay lifecycle, audio safety, gif encoding, UI polish

- add cancel_export command with AtomicBool flag
- shut down overlay clickthrough poll thread on app exit
- move set_overlay_clickthrough after capture starts (not before)
- add fps filter to capture pipeline to avoid bloated intermediate files
- add scale.max(0.1) floor in gif balanced mode
- warn when gif encode can't meet target after retries
- increase update apply script timeout and add retry loop
- add SAFETY comments to all 21 unsafe blocks in audio.rs
- remove dead output_path variable in capture.rs
- remove no-op gif_colors.min() call in encode retry
- add error toast dismiss button with 8-second auto-dismiss
- remove test fps values (1,2,5,10) from idle screen
- add duplicate hotkey validation in settings
- change picker window to 2560x1440
- add gitignore exception for src-tauri/gen/schemas/
This commit is contained in:
2026-05-29 23:23:02 +03:00
parent 9e52750a71
commit e9005415c4
8 changed files with 111 additions and 23 deletions
+18 -3
View File
@@ -344,9 +344,14 @@ fn cleanup_pass_logs(stem: &Path) {
fn encode_gif(ffmpeg: &Path, req: &TranscodeRequest) -> Result<()> {
let (mut scale_width, mut effective_fps) = gif_params(req, req.clip_width, req.clip_height);
let target = req.target_bytes;
let max_retries = 5;
let max_retries = 6;
for attempt in 0..max_retries {
// Last resort: use minimal settings to hit the target
if attempt == 5 {
scale_width = (scale_width / 2).max(60);
effective_fps = 1;
}
encode_gif_pass(ffmpeg, req, scale_width, effective_fps)?;
let actual = std::fs::metadata(&req.output)
@@ -402,7 +407,14 @@ fn encode_gif(ffmpeg: &Path, req: &TranscodeRequest) -> Result<()> {
);
}
// Final attempt was the best we could do
// All retries exhausted - warn if still over target
let final_size = std::fs::metadata(&req.output).map(|m| m.len()).unwrap_or(0);
if final_size > req.target_bytes {
tracing::warn!(
"gif encode: could not meet target size after {} attempts. Final: {} bytes (target: {})",
max_retries, final_size, req.target_bytes
);
}
Ok(())
}
@@ -468,7 +480,9 @@ fn encode_gif_pass(
pub fn gif_params(req: &TranscodeRequest, clip_width: u32, clip_height: u32) -> (u32, u32) {
let aspect = if clip_height > 0 { clip_width as f64 / clip_height as f64 } else { 16.0 / 9.0 };
// GIF LZW compression on typical screen content averages ~0.2 bytes/pixel.
// GIF LZW compression on typical screen content averages ~0.2 bytes/pixel at 256 colors.
// Real compression varies 3-5x depending on content (solid colors compress much better
// than gradients/noise). The retry loop in encode_gif handles correction on mismatch.
// Fewer colors = better compression. Adjust proportionally.
// 256 colors = 1.0x, 128 = ~0.85x, 64 = ~0.7x, 32 = ~0.55x, 16 = ~0.4x, 2 = ~0.2x
let color_factor = (req.gif_colors as f64 / 256.0).sqrt().clamp(0.15, 1.0);
@@ -506,6 +520,7 @@ pub fn gif_params(req: &TranscodeRequest, clip_width: u32, clip_height: u32) ->
} else {
1.0
};
let scale = scale.max(0.1);
let w = ((clip_width as f64 * scale).round() as u32 / 2).max(60) * 2;
let fps = ((requested_fps * scale).round() as u32).max(1).min(req.fps);