fix: made threads and niceness also optional.

This commit is contained in:
Didier Slof 2023-05-07 21:16:12 +02:00
parent e4f14f9531
commit 92833c21ce
Signed by: didier
GPG key ID: 01E71F18AA4398E5
3 changed files with 9 additions and 9 deletions

View file

@ -14,8 +14,8 @@ impl ConfigFFmpeg {
audio_codec: self.output.audio.codec.clone(),
audio_bitrate: if self.output.audio.bitrate > 0 { Some(self.output.audio.bitrate) } else { None },
threads: if self.process.threads > 0 { Some(self.process.threads) } else { None },
niceness: if self.process.niceness > 0 { Some(self.process.niceness) } else { None },
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 },
}
}
}

View file

@ -44,8 +44,8 @@ pub struct ConfigFiles {
#[derive(Serialize, Deserialize, Debug)]
pub struct ConfigFFmpegProcess {
pub threads: u8,
pub niceness: u8,
pub threads: Option<u8>,
pub niceness: Option<u8>,
}
#[derive(Serialize, Deserialize, Debug)]
@ -106,8 +106,8 @@ impl Config {
ffmpeg: ConfigFFmpeg {
path: String::from("/usr/bin/ffmpeg"),
process: ConfigFFmpegProcess {
threads: 0,
niceness: 0,
threads: Some(0),
niceness: Some(0),
},
output: ConfigFFmpegOutput {
format: String::from("webm"),
@ -134,7 +134,7 @@ impl Config {
}
}
}
pub fn is_debug(&self) -> bool {
match self.debug {
Some(debug) => debug,

View file

@ -44,8 +44,8 @@ fn main() {
info!("Processing file {}.", job.input);
let mut child = job.run(&config.ffmpeg).unwrap();
if (config.ffmpeg.process.niceness > 0) {
renice(child.id(), config.ffmpeg.process.niceness)
if (config.ffmpeg.process.niceness.unwrap_or(0)) > 0 {
renice(child.id(), config.ffmpeg.process.niceness.unwrap_or(0))
.expect("Failed to renice process.");
}
child.wait().expect("Failed to wait for process.");