mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Add audio drains & various fixes and adjustments
This commit is contained in:
@@ -13,6 +13,62 @@
|
||||
source
|
||||
});
|
||||
|
||||
const videoTrack = await input.getPrimaryVideoTrack();
|
||||
const audioTrack = await input.getPrimaryAudioTrack();;
|
||||
console.log(videoTrack.computeDuration());
|
||||
console.log(await audioTrack.computeDuration());
|
||||
|
||||
/*
|
||||
const audioTrack = await input.getPrimaryAudioTrack();
|
||||
const drain = new Metamuxer.AudioBufferDrain(audioTrack);
|
||||
|
||||
const context = new AudioContext();
|
||||
const startTime = context.currentTime;
|
||||
|
||||
for await (const { buffer, timestamp } of drain.buffers()) {
|
||||
const node = context.createBufferSource();
|
||||
node.buffer = buffer;
|
||||
node.connect(context.destination);
|
||||
const start = startTime + timestamp
|
||||
node.start(start);
|
||||
|
||||
if (start > context.currentTime + 5) {
|
||||
await new Promise(resolve => {
|
||||
const id = setInterval(() => {
|
||||
if (start < context.currentTime + 5) {
|
||||
clearInterval(id);
|
||||
resolve();
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
const drain = new Metamuxer.AudioDataDrain(audioTrack);
|
||||
|
||||
console.time()
|
||||
for await (const data of drain.data()) {
|
||||
data.close();
|
||||
}
|
||||
console.timeEnd()
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
const drain = new Metamuxer.EncodedAudioChunkDrain(audioTrack);
|
||||
|
||||
for await (const chunk of drain.chunks()) {
|
||||
console.log(chunk);
|
||||
|
||||
if (chunk.timestamp > 1e6) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
const videoTrack = await input.getPrimaryVideoTrack();
|
||||
const drain = new Metamuxer.VideoFrameDrain(videoTrack);
|
||||
const width = await videoTrack.getWidth();
|
||||
@@ -30,6 +86,7 @@
|
||||
context.drawImage(frame, 0, 0, width, height);
|
||||
frame.close();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
const drain = new Metamuxer.EncodedVideoChunkDrain(videoTrack);
|
||||
|
||||
Reference in New Issue
Block a user