From 839c1e1490e7cd856e6ada1dcfd82f3d4505c89c Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 2 Oct 2023 19:46:08 +0200 Subject: transcoding profiles --- stream/src/segment.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'stream/src') diff --git a/stream/src/segment.rs b/stream/src/segment.rs index fdef01c..51674d7 100644 --- a/stream/src/segment.rs +++ b/stream/src/segment.rs @@ -6,7 +6,7 @@ use anyhow::{anyhow, bail, Result}; use jellybase::{AssetLocationExt, CONF}; use jellycommon::{stream::StreamSpec, LocalTrack, Node}; -use jellytranscoder::snippet::{transcode, Encoding}; +use jellytranscoder::snippet::transcode; use log::warn; use tokio::{fs::File, io::DuplexStream}; use tokio_util::io::SyncIoBridge; @@ -23,16 +23,12 @@ pub async fn segment_stream( let track = spec.tracks[0]; let n = spec.index.ok_or(anyhow!("segment index missing"))?; - if let Some(width) = spec.width { - let width = width_steps(width); + if let Some(profile) = spec.profile { let location = transcode( "", - Encoding::Video { - codec: "libsvtav1", - preset: 8, - bitrate: spec.bitrate.unwrap_or(2_000_000), - width, - }, + CONF.transcoding_profiles + .get(profile) + .ok_or(anyhow!("profile out of range"))?, move |b| { tokio::task::spawn_blocking(move || { if let Err(err) = jellyremuxer::write_snippet_into( @@ -75,11 +71,3 @@ pub async fn segment_stream( Ok(()) } - -fn width_steps(width: usize) -> usize { - match width { - x if x >= 3840 => 3840, - x if x >= 1920 => 1920, - _ => 720, - } -} -- cgit v1.2.3-70-g09d2