Add Opus support to ISOBMFF demuxer

This commit is contained in:
Vanilagy
2025-01-02 14:19:17 +01:00
parent 8a8fbc264e
commit 7c5e31a93a
5 changed files with 87 additions and 6 deletions
+24 -1
View File
@@ -4,6 +4,27 @@
const fileInput = document.createElement('input');
fileInput.type = 'file';
document.body.append(fileInput);
const encoder = new AudioEncoder({
output: console.log,
error: console.error
});
encoder.configure({
codec: 'vorbis',
numberOfChannels: 2,
sampleRate: 48000,
bitrate: 128000
});
let audioData = new AudioData({
format: 'f32',
numberOfChannels: 2,
sampleRate: 48000,
timestamp: 0,
data: new Float32Array(2 * 48000),
numberOfFrames: 48000
});
encoder.encode(audioData);
fileInput.addEventListener('change', async () => {
const file = fileInput.files[0];
@@ -16,7 +37,9 @@
const audioTrack = await input.getPrimaryAudioTrack();
const drain = new Metamuxer.EncodedAudioChunkDrain(audioTrack);
console.log(await drain.getFirstChunk());
for await (const chunk of drain.chunks()) {
console.log(chunk)
}
/*
const videoTrack = await input.getPrimaryVideoTrack();