aboutsummaryrefslogtreecommitdiff
path: root/remuxer/src/codec_param/mod.rs
blob: 4fdb181acf31cfa83bbf39ef06753c0d1087512a (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
/*
    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) 2026 metamuffin <metamuffin.org>
*/

use crate::codec_param::{av1::av1_codec_param, hevc::hevc_codec_param, vp9::vp9_codec_param};
use winter_matroska::TrackEntry;

mod av1;
mod hevc;
mod vp9;

pub fn codec_param(te: &TrackEntry) -> String {
    let empty_cp = vec![];
    let cp = te.codec_private.as_ref().unwrap_or(&empty_cp);
    match te.codec_id.as_str() {
        "A_AAC" => "mp4a.40.2".to_string(),
        "A_FLAC" => "flac".to_string(),
        "A_OPUS" => "opus".to_string(),
        "A_VORBIS" => "vorbis".to_string(),

        "V_AV1" => av1_codec_param(cp),
        "V_MPEG4/ISO/AVC" => format!("avc1.{:02x}{:02x}{:02x}", cp[1], cp[2], cp[3]),
        "V_MPEGH/ISO/HEVC" => hevc_codec_param(cp),
        "V_VP9" => vp9_codec_param(te),

        "D_WEBVTT/SUBTITLES" => "webvtt".to_string(),
        "S_TEXT/ASS" => "ass".to_string(),

        x => todo!("{x:?}"),
    }
}