Fix incorrectly processed timestamps for fragmented MP4

This commit is contained in:
Vanilagy
2025-06-07 18:54:19 +02:00
parent 0359a7f2b1
commit f5a56e1f62
3 changed files with 53 additions and 13 deletions
+4 -4
View File
@@ -21,7 +21,7 @@
chunked: true,
chunkSize: 2**20
});
const outputFormat = new Metamuxer.Mp4OutputFormat();
const outputFormat = new Metamuxer.Mp4OutputFormat({ fastStart: 'fragmented' });
const button = document.createElement('button');
button.textContent = 'Cancel';
@@ -41,7 +41,7 @@
//numberOfChannels: 1,
//sampleRate: 4000
//discard: true
forceReencode: true,
//forceReencode: true,
},
/*
video: {
@@ -72,7 +72,7 @@
//width: 1280,
//discard: true,
//width: 640
forceReencode: true,
//forceReencode: true,
//rotate: 90
//width: 720 ?? 2160,
//height: 1280 ?? 3840,
@@ -85,7 +85,7 @@
},
trim: {
start: 0,
end: 40
end: 3
},
});
console.log(conversion);
+15 -3
View File
@@ -15,10 +15,17 @@
formats: Metamuxer.ALL_FORMATS,
source
});
let timestamps = [];
const videoTrack = await input.getPrimaryVideoTrack();
const sink = new Metamuxer.EncodedPacketSink(videoTrack);
for await (const packet of sink.packets()) {
if (packet.timestamp >= 2) break;
console.log(packet);
}
/*
let timestamps = [];
const packetSink = new Metamuxer.EncodedPacketSink(videoTrack);
for await (const packet of packetSink.packets()) {
if (packet.timestamp >= 1) {
@@ -71,22 +78,25 @@
7.253333333333333,
7.253333333333333,
];
*/
console.log(timestamps);
//return;
/*
console.log(timestamps);
const sink = new Metamuxer.EncodedPacketSink(videoTrack);
for await (const packet of sink.packets()) {
console.log(packet.sequenceNumber);
}
*/
/*
const sink = new Metamuxer.VideoSampleSink(videoTrack);
for await (const sample of sink.samplesAtTimestamps(timestamps)) {
console.log("wee", sample.timestamp);
sample.close();
}
console.log("don")
*/
/*
const sink = new Metamuxer.CanvasSink(videoTrack, { width: 320 });
@@ -100,6 +110,7 @@
/*
for (let i = 0; i < 40; i++) {
const count = Math.floor(50 * Math.random());
const timestamps = Array.from({ length: count }, () => Math.random() * 20).sort((a, b) => a-b);
@@ -112,6 +123,7 @@
}
console.log("DONE!")
*/