From 031b03e7e40779a5eaad7f40726458e6eb84d231 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 3 May 2025 00:52:43 +0200 Subject: [PATCH] always transcode for the highest/lowest resolutions --- src/main.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index a0b32e4..7d0a56b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use render_video::{ render::Renderer, time::parse_date }; -use std::fs; +use std::{collections::BTreeSet, fs}; #[derive(Debug, Parser)] struct Args { @@ -215,13 +215,17 @@ fn main() { // rescale the video if let Some(lowest_res) = args.transcode.or(preset.transcode) { - for res in Resolution::STANDARD_RESOLUTIONS.into_iter().rev() { - if res > project.source.metadata.as_ref().unwrap().source_res - || res > args.transcode_start.unwrap_or(preset.transcode_start) - || res < lowest_res - { - continue; - } + let highest_res = args.transcode_start.unwrap_or(preset.transcode_start); + let source_res = project.source.metadata.as_ref().unwrap().source_res; + let mut resolutions = Resolution::STANDARD_RESOLUTIONS + .into_iter() + .collect::>(); + resolutions.retain(|res| { + *res <= source_res && *res <= highest_res && *res >= lowest_res + }); + resolutions.insert(highest_res); + resolutions.insert(lowest_res); + for res in resolutions { if !project.progress.transcoded.contains(&res) { videos.push(renderer.rescale(&project.lecture, res).unwrap()); project.progress.transcoded.insert(res);