33 lines
No EOL
941 B
Rust
33 lines
No EOL
941 B
Rust
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()
|
|
}
|
|
} |