New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 736865 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Oct 5
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Feature



Sign in to add a comment

Add flac audio support to MediaRecorder

Project Member Reported by allieduncan@google.com, Jun 26 2017

Issue description

For 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.
 
This was intended as an audio/video issue (not Linux) - but I can't figure out how to change this post-creation....

Comment 2 by mcasas@chromium.org, Jun 28 2017

Components: Blink>MediaRecording
Labels: -Type-Bug Type-Feature
Cc: dalecur...@chromium.org
Status: Available (was: Unconfirmed)
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.
Project Member

Comment 4 by sheriffbot@chromium.org, Jul 12 2017

Labels: Hotlist-Google
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?
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.

Comment 7 by ttai@google.com, 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!
Cc: hongchan@chromium.org rtoy@chromium.org
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.

Comment 9 by rtoy@chromium.org, 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.
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?

Comment 11 by rtoy@chromium.org, 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.
Cc: ttai@google.com
Labels: OS-Android OS-Chrome OS-Mac OS-Windows
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

Comment 13 by ttai@google.com, 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!

Comment 14 by ttai@google.com, 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.
Status: WontFix (was: Available)
We already have support for uncompressed PCM audio recording thanks
to ttai@, so closing this bug.

Sign in to add a comment