diff --git a/src/main.rs b/src/main.rs index 44e034a..b978319 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ macro_rules! resolutions { } } - fn bitrate(self) -> &'static str { + fn bitrate(self) -> u64 { match self { $(Self::$res => $bitrate),+ } @@ -100,12 +100,12 @@ macro_rules! resolutions { } resolutions! { - nHD: 640 x 360 at "500k", - HD: 1280 x 720 at "1M", - FullHD: 1920 x 1080 at "2M", - WQHD: 2560 x 1440 at "3M", + nHD: 640 x 360 at 500_000, + HD: 1280 x 720 at 1_000_000, + FullHD: 1920 x 1080 at 2_000_000, + WQHD: 2560 x 1440 at 3_000_000, // TODO qsx muss mal sagen wieviel bitrate für 4k - UHD: 3840 x 2160 at "4M" + UHD: 3840 x 2160 at 4_000_000 } #[derive(Deserialize, Serialize)] diff --git a/src/render/ffmpeg.rs b/src/render/ffmpeg.rs index c01269f..ec76a8b 100644 --- a/src/render/ffmpeg.rs +++ b/src/render/ffmpeg.rs @@ -110,7 +110,7 @@ enum FfmpegFilter { pub(crate) struct Ffmpeg { inputs: Vec, filter: FfmpegFilter, - video_bitrate: Option<&'static str>, + video_bitrate: Option, output: FfmpegOutput, filter_idx: usize @@ -182,7 +182,7 @@ impl Ffmpeg { self } - pub fn set_video_bitrate(&mut self, bitrate: &'static str) -> &mut Self { + pub fn set_video_bitrate(&mut self, bitrate: u64) -> &mut Self { self.video_bitrate = Some(bitrate); self } @@ -272,7 +272,7 @@ impl Ffmpeg { cmd.arg("-c:v").arg("copy"); } if venc && self.video_bitrate.is_some() { - cmd.arg("-b:v").arg(self.video_bitrate.unwrap()); + cmd.arg("-b:v").arg(self.video_bitrate.unwrap().to_string()); } if aenc { cmd.arg("-c:a").arg("aac"); diff --git a/src/render/mod.rs b/src/render/mod.rs index 3b9257c..2aa7398 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -443,6 +443,15 @@ impl<'a> Renderer<'a> { // we're done :) ffmpeg.set_filter_output(overlay); + ffmpeg.set_video_bitrate( + project + .source + .metadata + .as_ref() + .unwrap() + .source_res + .bitrate() * 3 + ); ffmpeg.run()?; Ok(output)