use std::process::Command; pub struct FFmpegCommandOptions { pub input: String, pub output: String, pub video_codec: String, pub video_bitrate: Option, pub video_crf: Option, pub audio_codec: String, pub audio_bitrate: Option, pub overwrite: Option, pub extra_args: Vec, pub threads: Option, pub niceness: Option } impl FFmpegCommandOptions { pub fn to_args(&self) -> Vec { let mut args = Vec::new(); args.push("-i".to_string()); args.push(self.input.clone()); args.push("-c:v".to_string()); args.push(self.video_codec.clone()); args.push("-c:a".to_string()); args.push(self.audio_codec.clone()); if let Some(bitrate) = self.video_bitrate { args.push("-b:v".to_string()); args.push(bitrate.to_string()); } if let Some(crf) = self.video_crf { args.push("-crf".to_string()); args.push(crf.to_string()); } if let Some(bitrate) = self.audio_bitrate { args.push("-b:a".to_string()); args.push(bitrate.to_string()); } if let Some(threads) = self.threads { args.push("-threads".to_string()); args.push(threads.to_string()); } if let Some(niceness) = self.niceness { args.push("-threads".to_string()); args.push(niceness.to_string()); } if let Some(allow_overwrite) = self.overwrite { if allow_overwrite { args.push("-y".to_string()); } } args.append(&mut self.extra_args.clone()); args.push(self.output.clone()); args } pub fn to_command(&self, ffmpeg_path: &str) -> Command { let mut command = Command::new(ffmpeg_path); command.args(self.to_args()); command } }