fix(config): made process part optional

This commit is contained in:
Didier Slof 2023-05-08 10:30:04 +02:00
parent fe55238b10
commit 205380b689
Signed by: didier
GPG Key ID: 01E71F18AA4398E5
2 changed files with 12 additions and 10 deletions

View File

@ -67,7 +67,7 @@ pub struct ConfigFFmpeg {
pub path: String, pub path: String,
pub extra_args: Option<Vec<String>>, pub extra_args: Option<Vec<String>>,
pub overwrite: Option<bool>, pub overwrite: Option<bool>,
pub process: ConfigFFmpegProcess, pub process: Option<ConfigFFmpegProcess>,
pub output: ConfigFFmpegOutput, pub output: ConfigFFmpegOutput,
} }
@ -86,16 +86,16 @@ impl Config {
input_path: String::from("/data/input"), input_path: String::from("/data/input"),
output_path: String::from("/data/output"), output_path: String::from("/data/output"),
include: Vec::new(), include: Vec::new(),
cleanup: None cleanup: None,
}, },
ffmpeg: ConfigFFmpeg { ffmpeg: ConfigFFmpeg {
path: String::from("/usr/bin/ffmpeg"), path: String::from("/usr/bin/ffmpeg"),
extra_args: None, extra_args: None,
overwrite: None, overwrite: None,
process: ConfigFFmpegProcess { process: Some(ConfigFFmpegProcess {
threads: Some(0), threads: Some(0),
niceness: Some(0), niceness: Some(0),
}, }),
output: ConfigFFmpegOutput { output: ConfigFFmpegOutput {
format: String::from("webm"), format: String::from("webm"),
video: ConfigFFmpegOutputVideo { video: ConfigFFmpegOutputVideo {

View File

@ -43,7 +43,7 @@ fn main() {
let job = TranscodeJob::new( let job = TranscodeJob::new(
file.to_str().unwrap(), file.to_str().unwrap(),
output_path.to_str().unwrap() output_path.to_str().unwrap(),
); );
// check if overwriting // check if overwriting
@ -64,11 +64,13 @@ fn main() {
continue; continue;
} }
}; };
if (config.ffmpeg.process.niceness.unwrap_or(0)) > 0 { if let Some(process) = &config.ffmpeg.process {
match renice(child.id(), config.ffmpeg.process.niceness.unwrap()) { if (process.niceness.unwrap_or(0)) > 0 {
Ok(_) => {}, match renice(child.id(), process.niceness.unwrap_or(0)) {
Err(e) => { Ok(_) => {}
error!("Failed to renice ffmpeg process: {}", e); Err(e) => {
error!("Failed to renice ffmpeg process: {}", e);
}
} }
} }
} }