Fix ARG_MAX overflow: use filter_complex_script instead of -vf
- trace_video filter string can exceed macOS 256KB limit - Write filter to temp file, pass with -filter_complex_script
This commit is contained in:
@@ -330,15 +330,21 @@ async fn trace_video(
|
||||
|
||||
let tmp = std::env::temp_dir().join(format!("trace_{}.mp4", uuid::Uuid::new_v4()));
|
||||
let tmp_str = tmp.to_str().unwrap_or("").to_string();
|
||||
// Write filter to temp file to avoid ARG_MAX overflow
|
||||
let filter_file = std::env::temp_dir().join(format!("vf_{}.txt", uuid::Uuid::new_v4()));
|
||||
let filter_path = filter_file.to_str().unwrap_or("");
|
||||
let _ = std::fs::write(&filter_file, &vf);
|
||||
let status = std::process::Command::new("ffmpeg")
|
||||
.args([
|
||||
"-ss", &seek.to_string(), "-i", &video_path,
|
||||
"-t", &duration.to_string(), "-vf", &vf,
|
||||
"-t", &duration.to_string(),
|
||||
"-filter_complex_script", &filter_path,
|
||||
"-c:v", "libx264", "-preset", "ultrafast", "-crf", "28",
|
||||
"-an", "-movflags", "+faststart", "-y", &tmp_str,
|
||||
])
|
||||
.status()
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
let _ = std::fs::remove_file(&filter_file);
|
||||
if !status.success() {
|
||||
let _ = std::fs::remove_file(&tmp);
|
||||
return Err(StatusCode::INTERNAL_SERVER_ERROR);
|
||||
|
||||
Reference in New Issue
Block a user