diff options
author | metamuffin <metamuffin@disroot.org> | 2023-05-16 13:23:36 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-05-16 13:23:36 +0200 |
commit | d1594a140c430eba4489af7cd3d965bd93568a48 (patch) | |
tree | 0d6ae2b81dda1c3aafda918ead42b83fb761e9d1 /remuxer | |
parent | 542107bae31efeefe0e8072bfb05eef12171ce52 (diff) | |
download | jellything-d1594a140c430eba4489af7cd3d965bd93568a48.tar jellything-d1594a140c430eba4489af7cd3d965bd93568a48.tar.bz2 jellything-d1594a140c430eba4489af7cd3d965bd93568a48.tar.zst |
cue offsets corrected
Diffstat (limited to 'remuxer')
-rw-r--r-- | remuxer/src/lib.rs | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/remuxer/src/lib.rs b/remuxer/src/lib.rs index 34991e2..c68c9b0 100644 --- a/remuxer/src/lib.rs +++ b/remuxer/src/lib.rs @@ -138,7 +138,7 @@ impl RemuxerContext { blocks: Vec<(usize, BlockIndex)>, } - let segment_layout = { + let mut segment_layout: Vec<ClusterLayout> = { let mut cluster_pts = 0; let mut clusters = vec![]; let mut cluster = vec![]; @@ -173,7 +173,7 @@ impl RemuxerContext { + vint_length(cluster_content_size as u64) // size varint + cluster_content_size; clusters.push(ClusterLayout { - position: gp + 7860, // TODO this needs calculation + position: gp, // relative to the first cluster timestamp: cluster_pts, source_offsets, blocks: std::mem::take(&mut cluster), @@ -206,6 +206,38 @@ impl RemuxerContext { ); let timing_cp = Instant::now(); + let max_cue_size = 4 // cues id + + 8 // cues len + + ( // cues content + 1 // cp id + + 1 // cp len + + ( // cp content + 1 // ctime id, + + 1 // ctime len + + 8 // ctime content uint + + ( // ctps + 1 // ctp id + + 8 // ctp len + + (// ctp content + 1 // ctrack id + + 1 // ctrack size + + 1 // ctrack content int + // TODO break if inputs.len() >= 127 + + 1 // ccp id + + 1 // ccp len + + 8 // ccp content offset + ) + ) + ) * inputs.len() + ) * segment_layout.len() + + 1 // void id + + 8; // void len + + let first_cluster_offset_predict = max_cue_size + output.position(); + + // make the cluster position relative to the segment start as they should + segment_layout.iter_mut().for_each(|e| e.position += first_cluster_offset_predict - segment_offset); + output.write_tag(&MatroskaTag::Cues(Master::Collected( segment_layout .iter() @@ -225,8 +257,12 @@ impl RemuxerContext { }) .collect(), )))?; - + eprintln!("posbefore={}", output.position()); + output.write_padding(first_cluster_offset_predict)?; + eprintln!("posafter={}", output.position()); let first_cluster_offset = output.position(); + assert_eq!(first_cluster_offset, first_cluster_offset_predict); + eprintln!("{}", first_cluster_offset - segment_offset); let mut skip = 0; for (i, cluster) in segment_layout.iter().enumerate() { |