Skip to content
Snippets Groups Projects
Verified Commit 703cf9c0 authored by Dorian Koch's avatar Dorian Koch
Browse files

Make preset parameter optional

parent 57050709
No related branches found
No related tags found
Loading
Checking pipeline status
...@@ -22,7 +22,7 @@ struct Args { ...@@ -22,7 +22,7 @@ struct Args {
/// The preset of the lecture. Can be a toml file or a known course slug. /// The preset of the lecture. Can be a toml file or a known course slug.
#[clap(short, long)] #[clap(short, long)]
preset: String, preset: Option<String>,
#[cfg(feature = "mem_limit")] #[cfg(feature = "mem_limit")]
/// The memory limit for external tools like ffmpeg. /// The memory limit for external tools like ffmpeg.
...@@ -55,14 +55,16 @@ fn main() { ...@@ -55,14 +55,16 @@ fn main() {
// process arguments // process arguments
let directory = args.directory.canonicalize_utf8().unwrap(); let directory = args.directory.canonicalize_utf8().unwrap();
let preset = Preset::find(&args.preset).unwrap();
let course = preset.course;
// let's see if we need to initialise the project // let's see if we need to initialise the project
let project_path = directory.join("project.toml"); let project_path = directory.join("project.toml");
let mut project = if project_path.exists() { let mut project = if project_path.exists() {
toml::from_slice(&fs::read(&project_path).unwrap()).unwrap() toml::from_slice(&fs::read(&project_path).unwrap()).unwrap()
} else { } else {
assert!(args.preset.is_some());
let preset = Preset::find(&args.preset.unwrap()).unwrap();
let course = preset.course;
let dirname = directory.file_name().unwrap(); let dirname = directory.file_name().unwrap();
let date = let date =
parse_date(dirname).expect("Directory name is not in the expected format"); parse_date(dirname).expect("Directory name is not in the expected format");
...@@ -112,6 +114,8 @@ fn main() { ...@@ -112,6 +114,8 @@ fn main() {
stereo: args.stereo, stereo: args.stereo,
start: None, start: None,
end: None, end: None,
transcode_lowest: args.transcode.or(preset.transcode),
transcode_highest: args.transcode_start.unwrap_or(preset.transcode_start),
fast: Vec::new(), fast: Vec::new(),
questions: Vec::new(), questions: Vec::new(),
metadata: None metadata: None
...@@ -214,10 +218,10 @@ fn main() { ...@@ -214,10 +218,10 @@ fn main() {
}); });
// rescale the video // rescale the video
if let Some(lowest_res) = args.transcode.or(preset.transcode) { if let Some(lowest_res) = project.source.transcode_lowest {
for res in Resolution::STANDARD_RESOLUTIONS.into_iter().rev() { for res in Resolution::STANDARD_RESOLUTIONS.into_iter().rev() {
if res > project.source.metadata.as_ref().unwrap().source_res if res > project.source.metadata.as_ref().unwrap().source_res
|| res > args.transcode_start.unwrap_or(preset.transcode_start) || res > project.source.transcode_highest
|| res < lowest_res || res < lowest_res
{ {
continue; continue;
......
...@@ -150,6 +150,11 @@ pub struct ProjectSource { ...@@ -150,6 +150,11 @@ pub struct ProjectSource {
#[serde_as(as = "Option<DisplayFromStr>")] #[serde_as(as = "Option<DisplayFromStr>")]
pub end: Option<Time>, pub end: Option<Time>,
#[serde_as(as = "Option<DisplayFromStr>")]
pub transcode_lowest: Option<Resolution>,
#[serde_as(as = "DisplayFromStr")]
pub transcode_highest: Resolution,
#[serde(default)] #[serde(default)]
#[serde_as(as = "Vec<(DisplayFromStr, DisplayFromStr)>")] #[serde_as(as = "Vec<(DisplayFromStr, DisplayFromStr)>")]
pub fast: Vec<(Time, Time)>, pub fast: Vec<(Time, Time)>,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment