blob: 9bfa3aab24253d14bcc1c193a717696669038cce (
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
|
/*
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>
*/
use anyhow::{anyhow, Result};
use jellycache::cache_memory;
use jellyremuxer::{demuxers::create_demuxer_autodetect, matroska::Segment};
use std::{fs::File, path::Path, sync::Arc};
pub fn read_metadata(path: &Path) -> Result<Arc<Segment>> {
cache_memory("mkmeta-v4", 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()
})
})
}
|