mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 21:33:52 +02:00
TEMP timestamp iterator bugfix
This commit is contained in:
@@ -16,6 +16,72 @@
|
|||||||
source
|
source
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
const timestamps = [
|
||||||
|
4.16,
|
||||||
|
4.266666666666667,
|
||||||
|
4.373333333333333,
|
||||||
|
4.48,
|
||||||
|
4.586666666666667,
|
||||||
|
4.693333333333333,
|
||||||
|
4.8,
|
||||||
|
4.906666666666666,
|
||||||
|
5.013333333333334,
|
||||||
|
5.12,
|
||||||
|
5.226666666666667,
|
||||||
|
5.333333333333333,
|
||||||
|
5.4399999999999995,
|
||||||
|
5.546666666666667,
|
||||||
|
5.653333333333333,
|
||||||
|
5.76,
|
||||||
|
5.866666666666666,
|
||||||
|
5.973333333333333,
|
||||||
|
6.08,
|
||||||
|
6.186666666666666,
|
||||||
|
6.293333333333333,
|
||||||
|
6.4,
|
||||||
|
6.506666666666666,
|
||||||
|
6.613333333333333,
|
||||||
|
6.72,
|
||||||
|
6.826666666666666,
|
||||||
|
6.933333333333334,
|
||||||
|
7.039999999999999,
|
||||||
|
7.1466666666666665,
|
||||||
|
7.253333333333333
|
||||||
|
];
|
||||||
|
*/
|
||||||
|
const timestamps = [];
|
||||||
|
const videoTrack = await input.getPrimaryVideoTrack();
|
||||||
|
|
||||||
|
const packetSink = new Metamuxer.EncodedPacketSink(videoTrack);
|
||||||
|
for await (const packet of packetSink.packets()) {
|
||||||
|
if (packet.timestamp >= 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamps.push(packet.timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamps.sort((a, b) => a-b)
|
||||||
|
|
||||||
|
console.log(timestamps);
|
||||||
|
//return;
|
||||||
|
/*
|
||||||
|
const sink = new Metamuxer.EncodedPacketSink(videoTrack);
|
||||||
|
for await (const packet of sink.packets()) {
|
||||||
|
console.log(packet.sequenceNumber);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
const sink = new Metamuxer.CanvasSink(videoTrack, { width: 320 });
|
||||||
|
|
||||||
|
for await (const wrappedCanvas of sink.canvasesAtTimestamps(timestamps)) {
|
||||||
|
console.log(wrappedCanvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
const output = new Metamuxer.Output({
|
const output = new Metamuxer.Output({
|
||||||
format: new Metamuxer.Mp3OutputFormat(),
|
format: new Metamuxer.Mp3OutputFormat(),
|
||||||
target: new Metamuxer.BufferTarget()
|
target: new Metamuxer.BufferTarget()
|
||||||
@@ -49,6 +115,7 @@
|
|||||||
|
|
||||||
console.log(output.target.buffer)
|
console.log(output.target.buffer)
|
||||||
download(new Blob([output.target.buffer]), 'converted.mp3');
|
download(new Blob([output.target.buffer]), 'converted.mp3');
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+8
-3
@@ -526,6 +526,8 @@ export abstract class BaseMediaSampleSink<
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log('target', targetPacket);
|
||||||
|
|
||||||
const keyPacket = await packetSink.getKeyPacket(timestamp);
|
const keyPacket = await packetSink.getKeyPacket(timestamp);
|
||||||
if (!keyPacket) {
|
if (!keyPacket) {
|
||||||
pushToQueue(null);
|
pushToQueue(null);
|
||||||
@@ -533,15 +535,17 @@ export abstract class BaseMediaSampleSink<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastPacket && targetPacket.sequenceNumber < lastPacket.sequenceNumber) {
|
if (lastPacket && targetPacket.sequenceNumber < lastPacket.sequenceNumber) {
|
||||||
// We're going back in time with this one, let's flush and reset to an clean state
|
// console.log('FLUSH?', lastPacket, targetPacket.sequenceNumber, lastPacket.sequenceNumber);
|
||||||
|
// We're going back in time with this one, let's flush and reset to a clean state
|
||||||
await decoder.flush();
|
await decoder.flush();
|
||||||
timestampsOfInterest.length = 0;
|
timestampsOfInterest.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
lastKeyPacket
|
lastKeyPacket
|
||||||
&& keyPacket.sequenceNumber === lastKeyPacket.sequenceNumber
|
&& keyPacket.sequenceNumber === lastKeyPacket.sequenceNumber // => they're the same packet
|
||||||
&& targetPacket.timestamp >= lastPacket!.timestamp
|
// && targetPacket.timestamp >= lastPacket!.timestamp
|
||||||
|
&& targetPacket.sequenceNumber >= lastPacket!.sequenceNumber
|
||||||
) {
|
) {
|
||||||
assert(lastPacket);
|
assert(lastPacket);
|
||||||
|
|
||||||
@@ -558,6 +562,7 @@ export abstract class BaseMediaSampleSink<
|
|||||||
timestampsOfInterest.push(targetPacket.timestamp);
|
timestampsOfInterest.push(targetPacket.timestamp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// console.log('==== RESET');
|
||||||
// The key packet has changed
|
// The key packet has changed
|
||||||
lastKeyPacket = keyPacket;
|
lastKeyPacket = keyPacket;
|
||||||
lastPacket = keyPacket;
|
lastPacket = keyPacket;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
- https://github.com/Vanilagy/mp4-muxer/issues/83 tell him it's possible now
|
- https://github.com/Vanilagy/mp4-muxer/issues/83 tell him it's possible now
|
||||||
- textsubtitlesource, chunked piping
|
- textsubtitlesource, chunked piping
|
||||||
- More efficient MP3 loading when reading sequentially
|
- More efficient MP3 loading when reading sequentially
|
||||||
|
- toCanvasImageSource might return a new videoframe; how to handle this?
|
||||||
Reference in New Issue
Block a user