diff options
author | metamuffin <metamuffin@disroot.org> | 2023-07-31 19:53:01 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-07-31 19:53:01 +0200 |
commit | aeafba7847e189313df3025e6d6f291999b57350 (patch) | |
tree | bf7affdca28208695648bc9b18856cbb7049d1e8 /remuxer/src | |
parent | 0c651f11920350a4aa96aa24f8fe15b28390aed2 (diff) | |
download | jellything-aeafba7847e189313df3025e6d6f291999b57350.tar jellything-aeafba7847e189313df3025e6d6f291999b57350.tar.bz2 jellything-aeafba7847e189313df3025e6d6f291999b57350.tar.zst |
update server to new schema
Diffstat (limited to 'remuxer/src')
-rw-r--r-- | remuxer/src/import/mod.rs | 29 | ||||
-rw-r--r-- | remuxer/src/lib.rs | 9 |
2 files changed, 23 insertions, 15 deletions
diff --git a/remuxer/src/import/mod.rs b/remuxer/src/import/mod.rs index 4ccbd1c..1af74f6 100644 --- a/remuxer/src/import/mod.rs +++ b/remuxer/src/import/mod.rs @@ -12,11 +12,15 @@ use jellymatroska::{ unflatten::{IterWithPos, Unflat, Unflatten}, }; use log::{debug, error, info, trace, warn}; -use std::{collections::HashMap, fs::File, path::PathBuf}; +use std::{collections::HashMap, path::PathBuf}; -pub fn import_read(path: &PathBuf, input: &mut EbmlReader) -> Result<()> { +pub fn import_read( + path: &PathBuf, + input: &mut EbmlReader, +) -> Result<(Vec<SourceTrack>, Vec<LocalTrack>, Vec<SeekIndex>)> { let mut iteminfo = Vec::new(); let mut private = Vec::new(); + let mut seek_index = Vec::new(); while let Some(item) = input.next() { let item = match item { Ok(item) => item, @@ -45,14 +49,20 @@ pub fn import_read(path: &PathBuf, input: &mut EbmlReader) -> Result<()> { MatroskaTag::Segment(_) => { info!("segment start"); let mut children = Unflatten::new_with_end(input, item); - import_read_segment(path, &mut children, &mut iteminfo, &mut private)?; + import_read_segment( + path, + &mut children, + &mut iteminfo, + &mut private, + &mut seek_index, + )?; info!("segment end"); } _ => debug!("(r) tag ignored: {item:?}"), } } - Ok(()) + Ok((iteminfo, private, seek_index)) } fn import_read_segment( @@ -60,6 +70,7 @@ fn import_read_segment( segment: &mut Unflatten, iteminfo: &mut Vec<SourceTrack>, private: &mut Vec<LocalTrack>, + seek_index_out: &mut Vec<SeekIndex>, ) -> Result<Option<f64>> { let (mut timestamp_scale, mut duration) = (None, None); let mut seek_index = HashMap::new(); @@ -246,14 +257,10 @@ fn import_read_segment( }; } - for (tn, index) in seek_index { - info!("writing index {tn} with {} blocks", index.blocks.len()); - bincode::encode_into_std_write( - index, - &mut File::create(path.with_extension(&format!("si.{tn}")))?, - bincode::config::standard(), - )?; + for i in 0..iteminfo.len() { + seek_index_out.push(seek_index.get(&(i as u64)).unwrap().clone()) } + Ok(if let Some(duration) = duration { Some((duration * timestamp_scale.unwrap_or(1_000_000) as f64) / 1_000_000_000_f64) } else { diff --git a/remuxer/src/lib.rs b/remuxer/src/lib.rs index 5fc35f8..4a73edf 100644 --- a/remuxer/src/lib.rs +++ b/remuxer/src/lib.rs @@ -9,7 +9,7 @@ pub mod trim_writer; use crate::{segment_extractor::SegmentExtractIter, trim_writer::TrimWriter}; use anyhow::{anyhow, Context}; -use jellycommon::{BlockIndex, ItemPublic, LocalTrack, SeekIndex, SourceTrack, SourceTrackKind}; +use jellycommon::{BlockIndex, NodePublic, LocalTrack, SeekIndex, SourceTrack, SourceTrackKind}; use jellymatroska::{ block::Block, read::EbmlReader, @@ -39,7 +39,7 @@ impl RemuxerContext { writer: impl Write + 'static, range: Range<usize>, path_base: PathBuf, - item: ItemPublic, + item: NodePublic, track_sources: Vec<LocalTrack>, selection: Vec<usize>, webm: bool, @@ -65,7 +65,8 @@ impl RemuxerContext { .enumerate() .map(|(index, sel)| { let info = item - .media.as_ref() + .media + .as_ref() .unwrap() .tracks .get(*sel) @@ -228,7 +229,7 @@ impl RemuxerContext { + 1 // ccp id + 1 // ccp len + 8 // ccp content offset - ) + ) ) ) * inputs.len() ) * segment_layout.len() |