From 4a36d9e96853bf04d17f8377a7fbf862d108b9f1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 14 Apr 2025 14:33:52 +0200 Subject: start transcoding refactor --- transcoder/src/fragment.rs | 94 +++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'transcoder/src') diff --git a/transcoder/src/fragment.rs b/transcoder/src/fragment.rs index ff6a9db..b88339c 100644 --- a/transcoder/src/fragment.rs +++ b/transcoder/src/fragment.rs @@ -7,7 +7,7 @@ use crate::LOCAL_VIDEO_TRANSCODING_TASKS; use jellybase::{ cache::{async_cache_file, CachePath}, - common::jhls::EncodingProfile, + common::stream::StreamFormatInfo, }; use log::{debug, info}; use std::process::Stdio; @@ -21,7 +21,7 @@ use tokio::{ pub async fn transcode( key: &str, - enc: &EncodingProfile, + enc: &StreamFormatInfo, input: impl FnOnce(ChildStdin), ) -> anyhow::Result { async_cache_file( @@ -30,51 +30,51 @@ pub async fn transcode( let _permit = LOCAL_VIDEO_TRANSCODING_TASKS.acquire().await?; debug!("transcoding fragment with {enc:?}"); - let mut args = Vec::new(); - match enc { - EncodingProfile::Video { - codec, - preset, - bitrate, - width, - } => { - if let Some(width) = width { - args.push("-vf".to_string()); - args.push(format!("scale={width}:-1")); - } - args.push("-c:v".to_string()); - args.push(codec.to_string()); - if let Some(preset) = preset { - args.push("-preset".to_string()); - args.push(format!("{preset}")); - } - args.push("-b:v".to_string()); - args.push(format!("{bitrate}")); - } - EncodingProfile::Audio { - codec, - bitrate, - sample_rate, - channels, - } => { - if let Some(channels) = channels { - args.push("-ac".to_string()); - args.push(format!("{channels}")) - } - if let Some(sample_rate) = sample_rate { - args.push("-ar".to_string()); - args.push(format!("{sample_rate}")) - } - args.push("-c:a".to_string()); - args.push(codec.to_string()); - args.push("-b:a".to_string()); - args.push(format!("{bitrate}")); - } - EncodingProfile::Subtitles { codec } => { - args.push("-c:s".to_string()); - args.push(codec.to_string()); - } - }; + let mut args = Vec::::new(); + // match enc { + // EncodingProfile::Video { + // codec, + // preset, + // bitrate, + // width, + // } => { + // if let Some(width) = width { + // args.push("-vf".to_string()); + // args.push(format!("scale={width}:-1")); + // } + // args.push("-c:v".to_string()); + // args.push(codec.to_string()); + // if let Some(preset) = preset { + // args.push("-preset".to_string()); + // args.push(format!("{preset}")); + // } + // args.push("-b:v".to_string()); + // args.push(format!("{bitrate}")); + // } + // EncodingProfile::Audio { + // codec, + // bitrate, + // sample_rate, + // channels, + // } => { + // if let Some(channels) = channels { + // args.push("-ac".to_string()); + // args.push(format!("{channels}")) + // } + // if let Some(sample_rate) = sample_rate { + // args.push("-ar".to_string()); + // args.push(format!("{sample_rate}")) + // } + // args.push("-c:a".to_string()); + // args.push(codec.to_string()); + // args.push("-b:a".to_string()); + // args.push(format!("{bitrate}")); + // } + // EncodingProfile::Subtitles { codec } => { + // args.push("-c:s".to_string()); + // args.push(codec.to_string()); + // } + // }; info!("encoding with {:?}", args.join(" ")); let mut proc = Command::new("ffmpeg") -- cgit v1.2.3-70-g09d2