From 205380b689c425049385c9aa6cfdeb17812cc1ed Mon Sep 17 00:00:00 2001 From: Didier Date: Mon, 8 May 2023 10:30:04 +0200 Subject: [PATCH] fix(config): made process part optional --- src/configuration/mod.rs | 8 ++++---- src/main.rs | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/configuration/mod.rs b/src/configuration/mod.rs index 2e3a2e5..26099bb 100644 --- a/src/configuration/mod.rs +++ b/src/configuration/mod.rs @@ -67,7 +67,7 @@ pub struct ConfigFFmpeg { pub path: String, pub extra_args: Option>, pub overwrite: Option, - pub process: ConfigFFmpegProcess, + pub process: Option, pub output: ConfigFFmpegOutput, } @@ -86,16 +86,16 @@ impl Config { input_path: String::from("/data/input"), output_path: String::from("/data/output"), include: Vec::new(), - cleanup: None + cleanup: None, }, ffmpeg: ConfigFFmpeg { path: String::from("/usr/bin/ffmpeg"), extra_args: None, overwrite: None, - process: ConfigFFmpegProcess { + process: Some(ConfigFFmpegProcess { threads: Some(0), niceness: Some(0), - }, + }), output: ConfigFFmpegOutput { format: String::from("webm"), video: ConfigFFmpegOutputVideo { diff --git a/src/main.rs b/src/main.rs index 467979a..382a223 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,7 @@ fn main() { let job = TranscodeJob::new( file.to_str().unwrap(), - output_path.to_str().unwrap() + output_path.to_str().unwrap(), ); // check if overwriting @@ -64,11 +64,13 @@ fn main() { continue; } }; - if (config.ffmpeg.process.niceness.unwrap_or(0)) > 0 { - match renice(child.id(), config.ffmpeg.process.niceness.unwrap()) { - Ok(_) => {}, - Err(e) => { - error!("Failed to renice ffmpeg process: {}", e); + if let Some(process) = &config.ffmpeg.process { + if (process.niceness.unwrap_or(0)) > 0 { + match renice(child.id(), process.niceness.unwrap_or(0)) { + Ok(_) => {} + Err(e) => { + error!("Failed to renice ffmpeg process: {}", e); + } } } }