mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Modify audio encoder to fill gaps between timestamps with silence to ensure AV sync (fixes #176)
This commit is contained in:
+16
-1
@@ -14,7 +14,21 @@
|
||||
source: new Mediabunny.BlobSource(file),
|
||||
});
|
||||
|
||||
const videoTrack = await input.getPrimaryAudioTrack();
|
||||
const audioTrack = await input.getPrimaryAudioTrack();
|
||||
const sink = new Mediabunny.AudioSampleSink(audioTrack);
|
||||
|
||||
let lastEnd = 0;
|
||||
for await (const sample of sink.samples()) {
|
||||
if (sample.timestamp - lastEnd > 0) {
|
||||
console.warn(sample.timestamp - lastEnd)
|
||||
console.log(sample.timestamp, sample.duration, "diffie", sample.timestamp - lastEnd);
|
||||
}
|
||||
|
||||
lastEnd = sample.timestamp + sample.duration;
|
||||
sample.close();
|
||||
}
|
||||
|
||||
/*
|
||||
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
|
||||
|
||||
for await (const packet of sink.packets()) {
|
||||
@@ -22,6 +36,7 @@
|
||||
|
||||
if (packet.timestamp > 10) break;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
const sink = new Mediabunny.VideoSampleSink(videoTrack);
|
||||
|
||||
Reference in New Issue
Block a user