fix aspect ratio lock (send event before resize, enforce on lock), fix gif size estimate (0.5 -> 0.2 bytes/pixel for screen content)

This commit is contained in:
2026-05-27 21:12:00 +03:00
parent f15d984532
commit 3a631c0c24
3 changed files with 20 additions and 4 deletions
+4 -1
View File
@@ -417,7 +417,10 @@ fn encode_gif(ffmpeg: &Path, req: &TranscodeRequest) -> Result<()> {
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 };
let bytes_per_pixel_per_frame = 0.5_f64;
// GIF LZW compression on typical screen content averages ~0.2 bytes/pixel.
// The 0.5 constant was causing massive under-estimation (files at half target size).
// This is inherently approximate - complex content compresses worse, flat UI compresses better.
let bytes_per_pixel_per_frame = 0.2_f64;
let target_bytes = req.target_bytes as f64;
let requested_fps = req.fps as f64;
let duration = req.duration_secs;