diff options
-rw-r--r-- | remuxer/src/snippet.rs | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/remuxer/src/snippet.rs b/remuxer/src/snippet.rs index dcc3b15..afda1f3 100644 --- a/remuxer/src/snippet.rs +++ b/remuxer/src/snippet.rs @@ -120,19 +120,36 @@ pub fn write_snippet_into( let mut reader = SegmentExtractIter::new(&mut reader, private.track as u64); - // TODO: start using clusters again - for i in start_block_index..end_block_index { - let index_block = &index.blocks[i]; - let mut block = reader.next()?; + { + // TODO this one caused snippets to get dropped MSE for no reason + // for i in start_block_index..end_block_index { + // let index_block = &index.blocks[i]; + // let mut block = reader.next()?; - assert_eq!(index_block.size, block.data.len(), "seek index is wrong"); + // assert_eq!(index_block.size, block.data.len(), "seek index is wrong"); - block.track = 1; - block.timestamp_off = 0; - output.write_tag(&MatroskaTag::Cluster(Master::Collected(vec![ - MatroskaTag::Timestamp(index_block.pts - start_block.pts), - MatroskaTag::SimpleBlock(block.dump()), - ])))?; + // block.track = 1; + // block.timestamp_off = 0; + // output.write_tag(&MatroskaTag::Cluster(Master::Collected(vec![ + // MatroskaTag::Timestamp(index_block.pts - start_block.pts), + // MatroskaTag::SimpleBlock(block.dump()), + // ])))?; + // } + } + { + let mut blocks = vec![MatroskaTag::Timestamp(0)]; + for i in start_block_index..end_block_index { + let index_block = &index.blocks[i]; + let mut block = reader.next()?; + + assert_eq!(index_block.size, block.data.len(), "seek index is wrong"); + + block.track = 1; + // TODO this does generate overflows sometimes + block.timestamp_off = (index_block.pts - start_block.pts).try_into().unwrap(); + blocks.push(MatroskaTag::SimpleBlock(block.dump())) + } + output.write_tag(&MatroskaTag::Cluster(Master::Collected(blocks)))?; } output.write_tag(&MatroskaTag::Segment(Master::End))?; |