mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-03 05:43:50 +02:00
Merge branch 'main' of https://github.com/Vanilagy/metamuxer
This commit is contained in:
+3
-1
@@ -14,11 +14,13 @@
|
||||
source: new Mediabunny.BlobSource(file),
|
||||
});
|
||||
|
||||
const videoTrack = await input.getPrimaryVideoTrack();
|
||||
const videoTrack = await input.getPrimaryAudioTrack();
|
||||
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
|
||||
|
||||
for await (const packet of sink.packets()) {
|
||||
console.log(packet.timestamp, packet.duration, packet.timestamp + packet.duration);
|
||||
|
||||
if (packet.timestamp > 10) break;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -844,13 +844,13 @@ export class MatroskaDemuxer extends Demuxer {
|
||||
|
||||
blocks.splice(blockIndex, 1); // Remove the original block
|
||||
|
||||
const blockDuration = originalBlock.duration || frameCount * (track.defaultDuration ?? 0);
|
||||
|
||||
// Now, let's insert each frame as its own block
|
||||
for (let i = 0; i < frameCount; i++) {
|
||||
const frameSize = frameSizes[i]!;
|
||||
const frameData = readBytes(slice, frameSize);
|
||||
|
||||
const blockDuration = originalBlock.duration || (frameCount * (track.defaultDuration ?? 0));
|
||||
|
||||
// Distribute timestamps evenly across the block duration
|
||||
const frameTimestamp = originalBlock.timestamp + (blockDuration * i / frameCount);
|
||||
const frameDuration = blockDuration / frameCount;
|
||||
@@ -1181,9 +1181,8 @@ export class MatroskaDemuxer extends Demuxer {
|
||||
case EBMLId.DefaultDuration: {
|
||||
if (!this.currentTrack) break;
|
||||
|
||||
// Floored to reduce chance of overlapping packets (https://github.com/Vanilagy/mediabunny/issues/170)
|
||||
this.currentTrack.defaultDuration
|
||||
= Math.floor(this.currentTrack.segment.timestampFactor * readUnsignedInt(slice, size) / 1e9);
|
||||
= this.currentTrack.segment.timestampFactor * readUnsignedInt(slice, size) / 1e9;
|
||||
}; break;
|
||||
|
||||
case EBMLId.Name: {
|
||||
|
||||
Reference in New Issue
Block a user