blob: 4dedb76e569329227e40604dc712b6456991ac01 (
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
|
/*
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 anyhow::{Result, anyhow};
use jellycache::{Cache, HashKey};
use jellyremuxer::{demuxers::create_demuxer_autodetect, matroska::Segment};
use std::{fs::File, path::Path, sync::Arc};
pub fn read_metadata(cache: &Cache, path: &Path) -> Result<Arc<Segment>> {
cache.cache_memory(
&format!("media/stream-metadata/{}.json", HashKey(path)),
move || {
let media = File::open(path)?;
let mut media = create_demuxer_autodetect(Box::new(media))?
.ok_or(anyhow!("media format unknown"))?;
let info = media.info()?;
let tracks = media.tracks()?;
Ok(Segment {
info,
tracks,
..Default::default()
})
},
)
}
|