diff options
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) |