aboutsummaryrefslogtreecommitdiff
path: root/transcoder/src
diff options
context:
space:
mode:
Diffstat (limited to 'transcoder/src')
-rw-r--r--transcoder/src/fragment.rs16
-rw-r--r--transcoder/src/image.rs2
-rw-r--r--transcoder/src/lib.rs26
-rw-r--r--transcoder/src/subtitles.rs2
-rw-r--r--transcoder/src/thumbnail.rs2
5 files changed, 33 insertions, 15 deletions
diff --git a/transcoder/src/fragment.rs b/transcoder/src/fragment.rs
index 027e80f..dbb8f6d 100644
--- a/transcoder/src/fragment.rs
+++ b/transcoder/src/fragment.rs
@@ -3,16 +3,10 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
-use crate::LOCAL_VIDEO_TRANSCODING_TASKS;
+use crate::{Config, CONF, LOCAL_VIDEO_TRANSCODING_TASKS};
use anyhow::Result;
-use jellybase::{
- cache::{async_cache_file, CachePath},
- common::{
- config::TranscoderConfig,
- stream::{StreamFormatInfo, TrackKind},
- },
- CONF,
-};
+use jellycache::{async_cache_file, CachePath};
+use jellycommon::stream::{StreamFormatInfo, TrackKind};
use jellyremuxer::metadata::MatroskaTrackEntry;
use log::info;
use std::fmt::Write;
@@ -32,7 +26,7 @@ pub async fn transcode(
input_key: &str,
input: impl FnOnce(ChildStdin),
) -> anyhow::Result<CachePath> {
- let command = transcode_command(kind, orig_metadata, format, &CONF.transcoder).unwrap();
+ let command = transcode_command(kind, orig_metadata, format, &*CONF).unwrap();
async_cache_file("frag-tc", (input_key, &command), async |mut output| {
let _permit = LOCAL_VIDEO_TRANSCODING_TASKS.acquire().await?;
info!("encoding with {command:?}");
@@ -60,7 +54,7 @@ fn transcode_command(
kind: TrackKind,
orig_metadata: &MatroskaTrackEntry,
format: &StreamFormatInfo,
- config: &TranscoderConfig,
+ config: &Config,
) -> Result<String> {
let br = format.bitrate as u64;
let w = format.width.unwrap_or(0);
diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs
index c6e1367..6a7f693 100644
--- a/transcoder/src/image.rs
+++ b/transcoder/src/image.rs
@@ -6,7 +6,7 @@
use crate::LOCAL_IMAGE_TRANSCODING_TASKS;
use anyhow::Context;
use image::imageops::FilterType;
-use jellybase::cache::{async_cache_file, CachePath};
+use jellycache::{async_cache_file, CachePath};
use log::{debug, info};
use rgb::FromSlice;
use std::{
diff --git a/transcoder/src/lib.rs b/transcoder/src/lib.rs
index 1cf5d0d..c49f52c 100644
--- a/transcoder/src/lib.rs
+++ b/transcoder/src/lib.rs
@@ -5,11 +5,35 @@
*/
#![feature(exit_status_error)]
-use tokio::sync::Semaphore;
+use serde::{Deserialize, Serialize};
+use std::sync::LazyLock;
+use tokio::sync::{Mutex, Semaphore};
+
pub mod fragment;
pub mod image;
pub mod subtitles;
pub mod thumbnail;
+#[rustfmt::skip]
+#[derive(Debug, Deserialize, Serialize, Default)]
+pub struct Config {
+ #[serde(default)] pub enable_rkmpp: bool,
+ #[serde(default)] pub enable_rkrga: bool,
+ #[serde(default)] pub use_svtav1: bool,
+ #[serde(default)] pub use_rav1e: bool,
+ pub svtav1_preset: Option<u8>, // 0..=13, high is fast
+ pub rav1e_preset: Option<u8>, // 0..=10
+ pub aom_preset: Option<u8>, // 0..=8, high is fast
+ pub x264_preset: Option<String>,
+}
+
+static CONF: LazyLock<Config> = LazyLock::new(|| {
+ CONF_PRELOAD
+ .blocking_lock()
+ .take()
+ .expect("cache config not preloaded. logic error")
+});
+static CONF_PRELOAD: Mutex<Option<Config>> = Mutex::const_new(None);
+
static LOCAL_IMAGE_TRANSCODING_TASKS: Semaphore = Semaphore::const_new(8);
static LOCAL_VIDEO_TRANSCODING_TASKS: Semaphore = Semaphore::const_new(2);
diff --git a/transcoder/src/subtitles.rs b/transcoder/src/subtitles.rs
index 77b423d..d7e7b29 100644
--- a/transcoder/src/subtitles.rs
+++ b/transcoder/src/subtitles.rs
@@ -4,7 +4,7 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
use anyhow::{anyhow, bail, Context};
-use jellybase::common::jhls::SubtitleCue;
+use jellycommon::jhls::SubtitleCue;
use std::fmt::Write;
pub fn parse_subtitles(
diff --git a/transcoder/src/thumbnail.rs b/transcoder/src/thumbnail.rs
index caef397..8cefac3 100644
--- a/transcoder/src/thumbnail.rs
+++ b/transcoder/src/thumbnail.rs
@@ -1,5 +1,5 @@
use crate::LOCAL_IMAGE_TRANSCODING_TASKS;
-use jellybase::cache::{async_cache_file, CachePath};
+use jellycache::{async_cache_file, CachePath};
use log::info;
use std::{path::Path, process::Stdio};
use tokio::{io::copy, process::Command};