Add flac audio support to MediaRecorder |
|||||||
Issue descriptionFor context, see https://groups.google.com/a/google.com/forum/#!msg/hotword-eng/qXycB9q91Ok/9bR4AXuqAgAJ Currently Media Recorder (https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder) only supports webm, which is lossy compression. Speech team has started using Media Recorder for audio collection and would strongly prefer lossless 16kHz audio with no filtering.
,
Jun 28 2017
,
Jun 28 2017
Some additional context from e-mails: Android today doesn't link libflac, so we'd need to add it for this support or develop a MediaCodec based audio encoder which is a harder task.
,
Jul 12 2017
,
Sep 5 2017
I would like to work on this task. But, apparently, I dont have access to https://groups.google.com/a/google.com/forum/#!msg/hotword-eng/qXycB9q91Ok/9bR4AXuqAgAJ May I get access to the same?
,
Sep 5 2017
No, sorry that can't be shared. Really the only relevant point is that it would be nice to add flac codec support to MediaRecorder. Though we may want to add mp4 muxing support first since flac+webm is not spec compliant.
,
Oct 19 2017
It'd be totally okay to just get signed, linear 16-bit PCM (i.e., Audio/L16). We don't need libflac for that. I'd imagine (though I'm not sure) that that's actually the original output from the microphone. Basically we just want to save that directly as the audio. Would that be super hard? Thanks!
,
Oct 19 2017
You can already record a wav file like this in JavaScript: hhttps://developers.google.com/web/fundamentals/media/recording-audio/#access_the_raw_data_from_the_microphone +hongchan, rtoy to comment on the post-AudioWorklet recommended way for doing so.
,
Oct 19 2017
If a simple WAV file is ok, this is what we do when we need to regenerate a WAV reference file for a webaudio test: https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js?rcl=4e26f5e3875f6cea796ec6eebb86d0c97a51bba1&l=84 Can save as 32-bit float wav file too if you really want all the audio bits.
,
Oct 19 2017
That seems to use the OfflineAudioContext, which I guess is okay if you have a reasonable limit (~seconds) on the amount you'll allow to be recorded. Though doing this this way does results in a fair amount of memory use. Do you have a streaming recommendation that doesn't use ScriptProcessor?
,
Oct 19 2017
Oh, the intent is to take audio input and essentially save an unlimited amount of it somewhere? Can't think of any way to do that without using either a ScriptProcessor or an AudioWorklet and implementing the encoder there or streaming the data out to somewhere else to do the encoding. It would be cool, however, to be able to have MediaRecorder save to flac files.
,
Oct 23 2017
A potential option for allowing FLAC would be to use webm as a matroska container (similar to what we do for AVC1 [1]), marking it as A_FLAC [2]. Folks in cc: do you know if third_party/libflac supports encoding now? (And/or which platforms -- just to confirm #3) [1] https://cs.chromium.org/chromium/src/media/muxers/webm_muxer.cc?type=cs&q=webm_muxer+h264&sq=package:chromium&l=71 [2] search for A_FLAC in https://matroska.org/technical/specs/codecid/index.html [3] https://cs.chromium.org/chromium/src/third_party/flac/README.chromium?sq=package:chromium&dr
,
Oct 23 2017
Re #8: #8 is actually what we used to do. However, we found that some people recorded audio with gaps where the audio was missing. We were told this was due to the inability of the main thread to keep up with events, since that recorder isn't multi-threaded. We were urged to switch to the new MediaRecorder to solve that issue. If there's a way to fix the gap issue using the old recorder, then we'd be happy, too. Re #11: Our particular use case is to save "some" audio. Very likely under 1m. Also noting that many of our users will have very old phones with low capabilities. Side note - is there a way to turn off the audio processing (e.g., echo cancellation, etc.)? MediaRecorder seems to have some options for that, but I wasn't sure if it's possible to disable those. Thanks!
,
Oct 23 2017
Re #12: I don't know if third_party/libflac supports encoding. We only use it for decoding. And I have no knowledge about libflac in Android.
,
Oct 5
We already have support for uncompressed PCM audio recording thanks to ttai@, so closing this bug. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by allieduncan@google.com
, Jun 26 2017