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