aboutsummaryrefslogtreecommitdiff
path: root/transcoder/src/lib.rs
blob: 665f47023e40b82f39cc6db14e9ef85d9caefeca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2025 metamuffin <metamuffin.org>
*/
#![feature(exit_status_error)]

use serde::{Deserialize, Serialize};
use std::sync::{LazyLock, Mutex};
use tokio::sync::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>,
}

pub static CONF_PRELOAD: Mutex<Option<Config>> = Mutex::new(None);
static CONF: LazyLock<Config> = LazyLock::new(|| {
    CONF_PRELOAD
        .lock()
        .unwrap()
        .take()
        .expect("transcoder config not preloaded. logic error")
});

static LOCAL_IMAGE_TRANSCODING_TASKS: Semaphore = Semaphore::const_new(8);
static LOCAL_VIDEO_TRANSCODING_TASKS: Semaphore = Semaphore::const_new(2);