fix(config): moved ffmpeg configs to it's own file
This commit is contained in:
parent
205380b689
commit
226b19a177
2 changed files with 43 additions and 44 deletions
|
@ -1,6 +1,40 @@
|
|||
use crate::configuration::ConfigFFmpeg;
|
||||
use crate::ffmpeg::FFmpegCommandOptions;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegProcess {
|
||||
pub threads: Option<u8>,
|
||||
pub niceness: Option<u8>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegOutputVideo {
|
||||
pub codec: String,
|
||||
pub bitrate: u32,
|
||||
pub crf: u8,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegOutputAudio {
|
||||
pub codec: String,
|
||||
pub bitrate: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegOutput {
|
||||
pub format: String,
|
||||
pub video: ConfigFFmpegOutputVideo,
|
||||
pub audio: ConfigFFmpegOutputAudio,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpeg {
|
||||
pub path: String,
|
||||
pub extra_args: Option<Vec<String>>,
|
||||
pub overwrite: Option<bool>,
|
||||
pub process: Option<ConfigFFmpegProcess>,
|
||||
pub output: ConfigFFmpegOutput,
|
||||
}
|
||||
|
||||
impl ConfigFFmpeg {
|
||||
pub fn build_command_options<S: Into<String>>(&self, input_path: S, output_path: S) -> FFmpegCommandOptions {
|
||||
FFmpegCommandOptions {
|
||||
|
@ -18,8 +52,8 @@ impl ConfigFFmpeg {
|
|||
|
||||
extra_args: if self.extra_args.is_some() { self.extra_args.clone().unwrap() } else { Vec::new() },
|
||||
|
||||
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 },
|
||||
threads: if self.process.is_some() && self.process.as_ref().unwrap().threads.is_some() { Some(self.process.as_ref().unwrap().threads.unwrap()) } else { None },
|
||||
niceness: if self.process.is_some() && self.process.as_ref().unwrap().niceness.is_some() { Some(self.process.as_ref().unwrap().niceness.unwrap()) } else { None },
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,46 +36,11 @@ pub struct ConfigFiles {
|
|||
pub cleanup: Option<ConfigFilesCleanup>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegProcess {
|
||||
pub threads: Option<u8>,
|
||||
pub niceness: Option<u8>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegOutputVideo {
|
||||
pub codec: String,
|
||||
pub bitrate: u32,
|
||||
pub crf: u8,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegOutputAudio {
|
||||
pub codec: String,
|
||||
pub bitrate: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpegOutput {
|
||||
pub format: String,
|
||||
pub video: ConfigFFmpegOutputVideo,
|
||||
pub audio: ConfigFFmpegOutputAudio,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ConfigFFmpeg {
|
||||
pub path: String,
|
||||
pub extra_args: Option<Vec<String>>,
|
||||
pub overwrite: Option<bool>,
|
||||
pub process: Option<ConfigFFmpegProcess>,
|
||||
pub output: ConfigFFmpegOutput,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Config {
|
||||
pub debug: Option<bool>,
|
||||
pub files: ConfigFiles,
|
||||
pub ffmpeg: ConfigFFmpeg,
|
||||
pub ffmpeg: ffmpeg::ConfigFFmpeg,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
|
@ -88,22 +53,22 @@ impl Config {
|
|||
include: Vec::new(),
|
||||
cleanup: None,
|
||||
},
|
||||
ffmpeg: ConfigFFmpeg {
|
||||
ffmpeg: ffmpeg::ConfigFFmpeg {
|
||||
path: String::from("/usr/bin/ffmpeg"),
|
||||
extra_args: None,
|
||||
overwrite: None,
|
||||
process: Some(ConfigFFmpegProcess {
|
||||
process: Some(ffmpeg::ConfigFFmpegProcess {
|
||||
threads: Some(0),
|
||||
niceness: Some(0),
|
||||
}),
|
||||
output: ConfigFFmpegOutput {
|
||||
output: ffmpeg::ConfigFFmpegOutput {
|
||||
format: String::from("webm"),
|
||||
video: ConfigFFmpegOutputVideo {
|
||||
video: ffmpeg::ConfigFFmpegOutputVideo {
|
||||
codec: String::from("libsvtav1"),
|
||||
bitrate: 0,
|
||||
crf: 0,
|
||||
},
|
||||
audio: ConfigFFmpegOutputAudio {
|
||||
audio: ffmpeg::ConfigFFmpegOutputAudio {
|
||||
codec: String::from("libopus"),
|
||||
bitrate: 0,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue