quality pass 2: cached encoders, cancel in gif retry, overlay CSS split

- debug logging in picker changed to tracing::debug
- show_overlay uses visible_window_bounds helper
- encode_gif retry loop checks cancel flag between attempts
- list_encoders cached via OnceLock (ffmpeg -encoders runs once)
- remove unnecessary GifBudgetMode clone (is Copy)
- config test uses unique temp dir per process
- click highlights use 2px border instead of solid fill
- audio capture_loop polls at 5ms instead of 1ms
- overlay window loads minimal overlay.css instead of full app.css
- remove non-spec 960x540 preset
- Settings dirty detection uses field-by-field comparison
- Overlay startDragging catches errors
- pauseRec only emits recording-state on success
- Picker listener cleanup guards against unmount race
- add sync notes for previewDims and sr-only trim inputs
This commit is contained in:
2026-05-30 00:01:56 +03:00
parent d57e554ece
commit 2cd836b09e
10 changed files with 65 additions and 35 deletions
+16 -4
View File
@@ -85,7 +85,7 @@ fn click_filters(req: &TranscodeRequest) -> Option<String> {
crate::clicks::MouseButton::Middle => "green@0.6",
};
parts.push(format!(
"drawbox=x={x}:y={y}:w={size}:h={size}:color={color}:t=fill:enable='between(t,{t1:.3},{t2:.3})'"
"drawbox=x={x}:y={y}:w={size}:h={size}:color={color}:t=2:enable='between(t,{t1:.3},{t2:.3})'"
));
}
if parts.is_empty() {
@@ -159,7 +159,14 @@ pub fn transcode(ffmpeg: &Path, req: &TranscodeRequest) -> Result<()> {
}
}
fn list_encoders(ffmpeg: &Path) -> Result<HashSet<String>> {
use std::sync::OnceLock;
static ENCODER_CACHE: OnceLock<HashSet<String>> = OnceLock::new();
fn list_encoders(ffmpeg: &Path) -> Result<&'static HashSet<String>> {
if let Some(cached) = ENCODER_CACHE.get() {
return Ok(cached);
}
let out = Command::new(ffmpeg)
.args(["-hide_banner", "-encoders"])
.output()
@@ -180,7 +187,8 @@ fn list_encoders(ffmpeg: &Path) -> Result<HashSet<String>> {
}
set.insert(name.to_string());
}
Ok(set)
let _ = ENCODER_CACHE.set(set);
Ok(ENCODER_CACHE.get().unwrap())
}
fn pick_video_codec<'a>(
@@ -353,13 +361,16 @@ fn encode_gif(ffmpeg: &Path, req: &TranscodeRequest) -> Result<()> {
target_bytes: req.target_bytes,
fps: req.fps,
duration_secs: req.duration_secs,
gif_budget_mode: req.gif_budget_mode.clone(),
gif_budget_mode: req.gif_budget_mode,
};
let (mut scale_width, mut effective_fps) = gif_params(&budget_input, req.clip_width, req.clip_height);
let target = req.target_bytes;
let max_retries = 6;
for attempt in 0..max_retries {
if req.cancel.as_ref().map_or(false, |c| c.load(Ordering::Relaxed)) {
bail!("export cancelled");
}
// Last resort: use minimal settings to hit the target
if attempt == 5 {
scale_width = (scale_width / 2).max(60);
@@ -911,6 +922,7 @@ fn parse_frame_from_stderr(line: &str) -> Option<f64> {
mod tests {
use super::*;
// Paths are empty - these tests only exercise bitrate math, not ffmpeg.
fn dummy_request() -> TranscodeRequest {
TranscodeRequest {
input: PathBuf::new(),