2023-05-06 21:21:12 +00:00
|
|
|
use crate::configuration::ConfigFFmpeg;
|
|
|
|
use crate::ffmpeg::FFmpegCommandOptions;
|
|
|
|
|
|
|
|
impl ConfigFFmpeg {
|
|
|
|
pub fn build_command_options<S: Into<String>>(&self, input_path: S, output_path: S) -> FFmpegCommandOptions {
|
|
|
|
FFmpegCommandOptions {
|
|
|
|
input: input_path.into(),
|
|
|
|
output: output_path.into(),
|
|
|
|
|
|
|
|
video_codec: self.output.video.codec.clone(),
|
|
|
|
video_bitrate: if self.output.video.bitrate > 0 { Some(self.output.video.bitrate) } else { None },
|
|
|
|
video_crf: if self.output.video.crf > 0 { Some(self.output.video.crf) } else { None },
|
|
|
|
|
|
|
|
audio_codec: self.output.audio.codec.clone(),
|
|
|
|
audio_bitrate: if self.output.audio.bitrate > 0 { Some(self.output.audio.bitrate) } else { None },
|
|
|
|
|
2023-05-08 08:27:06 +00:00
|
|
|
overwrite: if self.overwrite.is_some() { Some(self.overwrite.unwrap()) } else { None },
|
|
|
|
|
|
|
|
extra_args: if self.extra_args.is_some() { self.extra_args.clone().unwrap() } else { Vec::new() },
|
|
|
|
|
2023-05-07 19:16:12 +00:00
|
|
|
threads: if self.process.threads.unwrap_or(0) > 0 { Some(self.process.threads.unwrap_or(0)) } else { None },
|
|
|
|
niceness: if self.process.niceness.unwrap_or(0) > 0 { Some(self.process.niceness.unwrap_or(0)) } else { None },
|
2023-05-06 21:21:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|