diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-16 20:06:01 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-16 20:06:01 +0200 |
commit | d26849375c70c795fdf664f9dfea68c273b6d483 (patch) | |
tree | 53ad4f0eff3604e80b27ff0abf0438ea6c69d432 /remuxer/src/extract.rs | |
parent | 1cd966f7454f052fda6c6c9ae1597479f05e23d9 (diff) | |
parent | cdf95d7b80bd2b78895671da8f462145bb5db522 (diff) | |
download | jellything-d26849375c70c795fdf664f9dfea68c273b6d483.tar jellything-d26849375c70c795fdf664f9dfea68c273b6d483.tar.bz2 jellything-d26849375c70c795fdf664f9dfea68c273b6d483.tar.zst |
Merge branch 'rewrite-stream'
Diffstat (limited to 'remuxer/src/extract.rs')
-rw-r--r-- | remuxer/src/extract.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/remuxer/src/extract.rs b/remuxer/src/extract.rs index 12e4003..15c1e9d 100644 --- a/remuxer/src/extract.rs +++ b/remuxer/src/extract.rs @@ -5,29 +5,22 @@ */ use crate::seek_index::get_seek_index; use anyhow::{anyhow, bail}; -use jellybase::common::LocalTrack; use jellymatroska::{block::Block, read::EbmlReader, Master, MatroskaTag}; use log::debug; use std::{fs::File, io::BufReader, path::PathBuf}; pub type TrackExtract = Vec<(u64, Option<u64>, Vec<u8>)>; -pub fn extract_track(path_base: PathBuf, track_info: LocalTrack) -> anyhow::Result<TrackExtract> { - let source_path = path_base.join(track_info.path); - let file = File::open(&source_path)?; +pub fn extract_track(path: PathBuf, track: u64) -> anyhow::Result<TrackExtract> { + let file = File::open(&path)?; let mut reader = EbmlReader::new(BufReader::new(file)); - let index = get_seek_index(&source_path)?; - let index = index - .get(&(track_info.track as u64)) - .ok_or(anyhow!("track missing"))?; + let index = get_seek_index(&path)?; + let index = index.get(&track).ok_or(anyhow!("track missing"))?; let mut out = Vec::new(); for b in &index.blocks { reader.seek(b.source_off, MatroskaTag::BlockGroup(Master::Start))?; let (duration, block) = read_group(&mut reader)?; - assert_eq!( - track_info.track, block.track as usize, - "seek index is wrong" - ); + assert_eq!(track, block.track, "seek index is wrong"); out.push((b.pts, duration, block.data)) } Ok(out) |