- From: Ashley Gullen <ashley@scirra.com>
- Date: Thu, 12 Mar 2015 00:29:39 +0000
- To: public-media-capture@w3.org
- Message-ID: <CAABs73jG7B5gANwNfUuvrKSO7rA10ADJxWaGcDnqOeLd9FUFeA@mail.gmail.com>
I have been experimenting with Firefox's Web Audio (decoding) and MediaRecorder (encoding) APIs to transcode audio between formats, such as transcoding a .wav file to Opus in the browser. A file can be decoded with the Web Audio context's decodeAudioData, and the resulting buffer connected to a media stream destination node, whose stream can be recorded with MediaRecorder. The big problem is this can only transcode audio in real-time. For a tool based on this to be useful, it should be able to transcode as fast as it can. This suggests the use of an OfflineAudioContext, but these cannot create media stream destination nodes (at least in Firefox, when I tried). It's not clear to me, but I get the impression a MediaStream is a real-time stream and cannot go faster-than-realtime anyway. Does there need to be a new API to enable this? For example one solution could be to pass a Web Audio AudioBuffer directly to MediaRecorder instead of a MediaStream. AudioBuffers provide a sample rate, channel count, length and contain audio data, which seems to be everything MediaRecorder needs to know for fast-as-possible encoding. One other problem I had which may simply be a Firefox bug is that starting the MediaRecorder and audio buffer source at the same time with code like this: mediaRecorder.start(); bufferSource.start(); ...appeared to skip the very beginning of the audio buffer. I guess MediaRecorder takes a moment to start actually capturing audio, and I should start the buffer source in mediaRecorder.onstart, but that function was not firing in Firefox. (Not yet implemented?) For transcoding it is important that the MediaRecorder can capture the exact same number of samples as are present in the original audio buffer. Ashley Gullen Scirra.com
Received on Thursday, 12 March 2015 00:30:08 UTC