feats: added renice module added jobs added ffmpeg command builders.
This commit is contained in:
parent
c43fd906cd
commit
a905cdd4b9
10 changed files with 205 additions and 36 deletions
33
src/transcode/job.rs
Normal file
33
src/transcode/job.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
use std::path::PathBuf;
|
||||
use std::process::{Child, Command};
|
||||
use crate::configuration::{Config, ConfigFFmpeg};
|
||||
|
||||
pub struct TranscodeJob {
|
||||
pub input: String,
|
||||
pub output: String
|
||||
}
|
||||
|
||||
impl TranscodeJob {
|
||||
pub fn new<S: Into<String>>(input: S, output: S) -> TranscodeJob {
|
||||
TranscodeJob {
|
||||
input: input.into(),
|
||||
output: output.into()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_command(&self, ffmpeg_config: &ConfigFFmpeg) -> Command {
|
||||
let options = ffmpeg_config.build_command_options(&self.input, &self.output);
|
||||
let mut command = Command::new("ffmpeg");
|
||||
command.args(options.to_args());
|
||||
command
|
||||
}
|
||||
|
||||
pub fn check_if_exists(&self) -> bool {
|
||||
std::path::Path::new(&self.output).exists()
|
||||
}
|
||||
|
||||
pub fn run(&self, ffmpeg_config: &ConfigFFmpeg) -> Result<Child, std::io::Error> {
|
||||
let mut command = self.build_command(ffmpeg_config);
|
||||
command.spawn()
|
||||
}
|
||||
}
|
1
src/transcode/mod.rs
Normal file
1
src/transcode/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod job;
|
Loading…
Add table
Add a link
Reference in a new issue