is audio supported?
xeoshow opened this issue · comments
Hi,
Just would like to know: when I am recording, I also have a background music which should be recorded, is this supported?
Thanks a lot.
Hi,
I don't intend to support Audio just yet, unless it can be added without increasing the complexity of the encoders. mp4-muxer demo and extending the WebCodecsEncoder would be a good place to start, but so far I have managed by merging audio and video on the file system after the export with ffmpeg.
@dmnsgn Is there any way to get access to the muxer? I'm seeing mp4-muxer has methods to add audio data, but I'm not sure how to access those methods
@dmnsgn Is there any way to get access to the muxer? I'm seeing mp4-muxer has methods to add audio data, but I'm not sure how to access those methods
For the WebCodecsEncoder, you can pass muxerOptions
and the muxer is added to the instance:
So something like:
const audioSampleRate = 44100;
const encoder = new Encoders.WebCodecsEncoder({
muxerOptions: {
codec: 'aac',
sampleRate: audioSampleRate,
numberOfChannels: 1
}
})
const { muxer } = encoder;
const audioEncoder = new AudioEncoder({
output: (chunk, meta) => muxer.addAudioChunk(chunk, meta),
error: e => console.error(e)
});
audioEncoder.configure({
codec: 'mp4a.40.2',
numberOfChannels: 1,
sampleRate: audioSampleRate,
bitrate: 128000
});
// ... use the audioEncoder to write data
// ... overwrite encoder.encode to add await audioEncoder.flush() after await this.encoder.flush();