this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

🚸 Show commandline when ffmpeg errors out

+51 -47
+51 -47
src/video/encoders/ffmpeg.rs
··· 4 4 ui::Pretty, 5 5 video::{encoders::Encoder, engine::EngineOutput}, 6 6 }; 7 - use anyhow::Result; 7 + use anyhow::{Result, anyhow}; 8 8 use measure_time::debug_time; 9 9 use std::{fs::File, io::Write, path::PathBuf, sync::Arc}; 10 10 ··· 24 24 ) -> Result<FFMpegEncoder> { 25 25 debug_time!("setup_encoder"); 26 26 let output_path: PathBuf = output_path.into(); 27 + 28 + let mut command = std::process::Command::new("ffmpeg"); 29 + command 30 + // Audio // 31 + // Take non-0 starting point into account 32 + .args(["-ss", &self.start_rendering_at.seconds_string()]) 33 + // File 34 + .args(["-i", self.audiofile.to_str().unwrap()]) 35 + // 36 + // Video // 37 + // Raw video input 38 + .args(["-f", "rawvideo"]) 39 + // RGBA Pixels 40 + .args(["-pixel_format", "rgba"]) 41 + // Dimensions 42 + .args(["-video_size", &format!("{width}x{height}")]) 43 + // FPS 44 + .args(["-framerate", &self.fps.to_string()]) 45 + // Input from pipe 46 + .args(["-i", "-"]) 47 + .stdin(std::process::Stdio::piped()) 48 + // 49 + // Mapping // 50 + // Audio from first input 51 + .args(["-map", "0:a"]) 52 + // Video from second input 53 + .args(["-map", "1:v"]) 54 + // Use shortest stream for final duration 55 + .arg("-shortest") 56 + // 57 + // Output // 58 + // Write to file 59 + .arg(output_path.to_str().unwrap()) 60 + // Debug ffmpeg too if shapemaker is debugging 61 + .args([ 62 + "-loglevel", 63 + (if log::log_enabled!(log::Level::Debug) { 64 + "debug" 65 + } else { 66 + "error" 67 + }), 68 + ]) 69 + // Put stdout/stderr here so that it doesn't mess with progress bars 70 + .stdout(File::create("ffmpeg_stdout.log")?) 71 + .stderr(File::create("ffmpeg_stderr.log")?); 72 + 73 + let commandline = format!("{:?}", &command); 27 74 28 75 Ok(FFMpegEncoder { 29 76 destination: output_path.clone(), 30 77 fontdb: self.initial_canvas.fontdb.clone(), 31 78 pixmap: create_pixmap(width, height), 32 - process: std::process::Command::new("ffmpeg") 33 - // Audio // 34 - // Take non-0 starting point into account 35 - .args(["-ss", &self.start_rendering_at.seconds_string()]) 36 - // File 37 - .args(["-i", self.audiofile.to_str().unwrap()]) 38 - // 39 - // Video // 40 - // Raw video input 41 - .args(["-f", "rawvideo"]) 42 - // RGBA Pixels 43 - .args(["-pixel_format", "rgba"]) 44 - // Dimensions 45 - .args(["-video_size", &format!("{width}x{height}")]) 46 - // FPS 47 - .args(["-framerate", &self.fps.to_string()]) 48 - // Input from pipe 49 - .args(["-i", "-"]) 50 - .stdin(std::process::Stdio::piped()) 51 - // 52 - // Mapping // 53 - // Audio from first input 54 - .args(["-map", "0:a"]) 55 - // Video from second input 56 - .args(["-map", "1:v"]) 57 - // Use shortest stream for final duration 58 - .arg("-shortest") 59 - // 60 - // Output // 61 - // Write to file 62 - .arg(output_path.to_str().unwrap()) 63 - // Debug ffmpeg too if shapemaker is debugging 64 - .args([ 65 - "-loglevel", 66 - (if log::log_enabled!(log::Level::Debug) { 67 - "debug" 68 - } else { 69 - "error" 70 - }), 71 - ]) 72 - // Put stdout/stderr here so that it doesn't mess with progress bars 73 - .stdout(File::create("ffmpeg_stdout.log")?) 74 - .stderr(File::create("ffmpeg_stderr.log")?) 75 - // 76 - // Spawn it! 77 - .spawn()?, 79 + process: command 80 + .spawn() 81 + .map_err(|e| anyhow!("Could not run {commandline}: {e:?}",))?, 78 82 }) 79 83 } 80 84 }