fix: address final review findings (clip reset, codecs, paths, timeline)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-21 11:25:28 -04:00
parent 169d3d5592
commit 149ce3da21
9 changed files with 70 additions and 5 deletions

View File

@@ -23,11 +23,20 @@ pub fn build_ffmpeg_args(
args.extend(["-c".to_string(), "copy".to_string()]);
}
CutMode::Precise { format: _ } => {
let ext = Path::new(output)
.extension()
.map(|e| e.to_string_lossy().to_ascii_lowercase())
.unwrap_or_default();
let (video_codec, audio_codec) = match ext.as_str() {
"webm" => ("libvpx-vp9", "libopus"),
"mp4" | "mkv" => ("libx264", "aac"),
_ => ("libx264", "aac"),
};
args.extend([
"-c:v".to_string(),
"libx264".to_string(),
video_codec.to_string(),
"-c:a".to_string(),
"aac".to_string(),
audio_codec.to_string(),
]);
}
}
@@ -36,6 +45,20 @@ pub fn build_ffmpeg_args(
args
}
pub fn expand_tilde_path(path: &str) -> String {
if path == "~" {
return dirs::home_dir()
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_else(|| path.to_string());
}
if let Some(rest) = path.strip_prefix("~/") {
if let Some(home) = dirs::home_dir() {
return home.join(rest).to_string_lossy().to_string();
}
}
path.to_string()
}
pub fn generate_output_path(
output_dir: &str,
video_title: &str,
@@ -206,6 +229,18 @@ mod tests {
let args = build_ffmpeg_args(&clip, "input.mp4", "output.mp4", &mode);
assert!(args.contains(&"-c:v".to_string()));
assert!(args.contains(&"libx264".to_string()));
assert!(args.contains(&"aac".to_string()));
let webm_args = build_ffmpeg_args(&clip, "input.mp4", "output.webm", &mode);
assert!(webm_args.contains(&"libvpx-vp9".to_string()));
assert!(webm_args.contains(&"libopus".to_string()));
}
#[test]
fn test_expand_tilde_path() {
let expanded = expand_tilde_path("~/Videos");
assert!(!expanded.starts_with("~/"));
assert!(expanded.ends_with("Videos") || expanded.contains("Videos"));
}
#[test]