From 4a36d9e96853bf04d17f8377a7fbf862d108b9f1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 14 Apr 2025 14:33:52 +0200 Subject: start transcoding refactor --- common/src/config.rs | 61 ++++++++++++++++++---------------------------------- common/src/jhls.rs | 27 ----------------------- common/src/stream.rs | 3 ++- 3 files changed, 23 insertions(+), 68 deletions(-) (limited to 'common/src') diff --git a/common/src/config.rs b/common/src/config.rs index d7682df..a0dc459 100644 --- a/common/src/config.rs +++ b/common/src/config.rs @@ -4,7 +4,7 @@ Copyright (C) 2025 metamuffin */ -use crate::{jhls::EncodingProfile, user::PermissionSet}; +use crate::user::PermissionSet; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; @@ -20,11 +20,30 @@ pub struct GlobalConfig { #[serde(default = "default::cache_path")] pub cache_path: PathBuf, #[serde(default = "default::media_path")] pub media_path: PathBuf, #[serde(default = "default::secrets_path")] pub secrets_path: PathBuf, - #[serde(default = "default::transcoding_profiles")] pub transcoding_profiles: Vec, #[serde(default = "default::max_in_memory_cache_size")] pub max_in_memory_cache_size: usize, #[serde(default)] pub admin_username: Option, #[serde(default = "default::login_expire")] pub login_expire: i64, #[serde(default)] pub default_permission_set: PermissionSet, + #[serde(default)] encoders: EncoderPreferences, +} + +#[derive(Debug, Deserialize, Serialize, Default)] +pub struct EncoderPreferences { + avc: Option, + hevc: Option, + vp8: Option, + vp9: Option, + av1: Option, +} + +#[derive(Debug, Deserialize, Serialize)] +enum EncoderClass { + Aom, + Svt, + X26n, + Vpx, + Vaapi, + Rkmpp, } #[derive(Serialize, Deserialize, Debug, Default)] @@ -59,7 +78,6 @@ pub struct ApiSecrets { } mod default { - use crate::jhls::EncodingProfile; use std::path::PathBuf; pub fn login_expire() -> i64 { @@ -83,43 +101,6 @@ mod default { pub fn max_in_memory_cache_size() -> usize { 50_000_000 } - pub fn transcoding_profiles() -> Vec { - vec![ - EncodingProfile::Video { - codec: "libsvtav1".to_string(), - preset: Some(8), - bitrate: 2_000_000, - width: Some(1920), - }, - EncodingProfile::Video { - codec: "libsvtav1".to_string(), - preset: Some(8), - bitrate: 1_200_000, - width: Some(1280), - }, - EncodingProfile::Video { - codec: "libsvtav1".to_string(), - preset: Some(8), - bitrate: 300_000, - width: Some(640), - }, - EncodingProfile::Audio { - codec: "libopus".to_string(), - bitrate: 128_000, - sample_rate: None, - channels: Some(2), - }, - EncodingProfile::Audio { - codec: "libopus".to_string(), - bitrate: 64_000, - sample_rate: None, - channels: Some(2), - }, - EncodingProfile::Subtitles { - codec: "webvtt".to_string(), - }, - ] - } } fn return_true() -> bool { diff --git a/common/src/jhls.rs b/common/src/jhls.rs index 6dc976b..90f48f5 100644 --- a/common/src/jhls.rs +++ b/common/src/jhls.rs @@ -5,33 +5,6 @@ */ use bincode::{Decode, Encode}; use serde::{Deserialize, Serialize}; -use std::ops::Range; - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct JhlsTrackIndex { - pub extra_profiles: Vec, - pub fragments: Vec>, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum EncodingProfile { - Video { - codec: String, - preset: Option, - bitrate: usize, - width: Option, - }, - Audio { - codec: String, - bitrate: usize, - channels: Option, - sample_rate: Option, - }, - Subtitles { - codec: String, - }, -} #[derive(Debug, Serialize, Deserialize, Encode, Decode)] pub struct SubtitleCue { diff --git a/common/src/stream.rs b/common/src/stream.rs index 75349cc..a14fd57 100644 --- a/common/src/stream.rs +++ b/common/src/stream.rs @@ -91,7 +91,8 @@ pub struct StreamFormatInfo { pub remux: bool, pub containers: Vec, - pub pixel_count: Option, + pub width: Option, + pub height: Option, pub samplerate: Option, pub channels: Option, pub bit_depth: Option, -- cgit v1.2.3-70-g09d2