fix(config): made process part optional
This commit is contained in:
parent
fe55238b10
commit
205380b689
2 changed files with 12 additions and 10 deletions
|
@ -67,7 +67,7 @@ pub struct ConfigFFmpeg {
|
|||
pub path: String,
|
||||
pub extra_args: Option<Vec<String>>,
|
||||
pub overwrite: Option<bool>,
|
||||
pub process: ConfigFFmpegProcess,
|
||||
pub process: Option<ConfigFFmpegProcess>,
|
||||
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 {
|
||||
|
|
10
src/main.rs
10
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,14 +64,16 @@ fn main() {
|
|||
continue;
|
||||
}
|
||||
};
|
||||
if (config.ffmpeg.process.niceness.unwrap_or(0)) > 0 {
|
||||
match renice(child.id(), config.ffmpeg.process.niceness.unwrap()) {
|
||||
Ok(_) => {},
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(e) = child.wait() {
|
||||
fail(&job, &format!("Failed to wait for ffmpeg process: {}", e));
|
||||
|
|
Loading…
Reference in a new issue