|
|
|
@ -2,7 +2,7 @@ use config::Config;
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
use std::process;
|
|
|
|
|
use std::{thread, time};
|
|
|
|
|
use log::{info};
|
|
|
|
|
use log::{debug, info};
|
|
|
|
|
|
|
|
|
|
use crate::util::io;
|
|
|
|
|
use super::repository::Repository;
|
|
|
|
@ -57,13 +57,20 @@ impl Transcoder {
|
|
|
|
|
|
|
|
|
|
fn transcode(&self, file: &str) {
|
|
|
|
|
let ingest_file = Path::new(&self.repository.ingest_dir).join(file);
|
|
|
|
|
let output_file = Path::new(&self.repository.output_dir).join(file);
|
|
|
|
|
let video_format = &self.config.get_string("transcoder.video_format").unwrap();
|
|
|
|
|
let output_stem = Path::new(file).file_stem().unwrap();
|
|
|
|
|
let output_bits = vec![output_stem.to_str().unwrap(), &video_format];
|
|
|
|
|
let output_name = output_bits.join(".");
|
|
|
|
|
let output_file = Path::new(&self.repository.output_dir).join(output_name);
|
|
|
|
|
|
|
|
|
|
let video_codec = &self.config.get_string("transcoder.video_codec").unwrap();
|
|
|
|
|
info!("Transcoding {} to {} with the {} encoder.", ingest_file.display(), output_file.display(), video_codec);
|
|
|
|
|
|
|
|
|
|
let cmd_output = process::Command::new("/usr/bin/ffmpeg")
|
|
|
|
|
.arg("-i") .arg(&*ingest_file.to_string_lossy())
|
|
|
|
|
.arg("-y")
|
|
|
|
|
.arg("-f") .arg(&self.config.get_string("transcoder.video_format").unwrap())
|
|
|
|
|
.arg("-c:v") .arg(&self.config.get_string("transcoder.video_codec").unwrap())
|
|
|
|
|
.arg("-f") .arg(&video_format)
|
|
|
|
|
.arg("-c:v") .arg(&video_codec)
|
|
|
|
|
.arg("-s") .arg(&self.config.get_string("transcoder.video_resolution").unwrap())
|
|
|
|
|
.arg("-r") .arg(format!("{}", self.config.get_string("transcoder.video_framerate").unwrap()))
|
|
|
|
|
.arg("-vf") .arg(format!("format={}", &self.config.get_string("transcoder.video_color").unwrap()))
|
|
|
|
@ -76,6 +83,6 @@ impl Transcoder {
|
|
|
|
|
assert!(cmd_output.status.success());
|
|
|
|
|
|
|
|
|
|
let results_raw = &String::from_utf8_lossy(&cmd_output.stderr);
|
|
|
|
|
info!("{}", results_raw);
|
|
|
|
|
debug!("{}", results_raw);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|