MediaRecorder records only silence for remapped null sink

63 views
Skip to first unread message

guest271314

unread,
Jun 25, 2022, 5:03:36 PM6/25/22
to media-dev
This used used to record the user-defined MediaStreamTrack. Records only silence on Chromium 105.

pactl load-module module-remap-source \ master="$(pactl list | grep -A2 'Source #' | grep 'Name: .*\.monitor$' | cut -d" " -f2)" \ source_name=virtmic source_properties=device.description=Virtual_Microphone

var recorder;
navigator.mediaDevices.getUserMedia({audio: true})
.then(async stream => {
  const [track] = stream.getAudioTracks();
  const devices = await navigator.mediaDevices.enumerateDevices();
  console.log(devices, track.label, track.getSettings(), await track.getConstraints());
  const device = devices.find(({label}) => label === 'Virtual_Microphone');
  if (track.getSettings().deviceId === device.deviceId) {
    return stream;
  } else {
  track.stop();
    return navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact: device.deviceId}}});
  }
})
.then(async stream => {
   // do stuff with rempapped monitor device
   recorder = new MediaRecorder(stream);
   recorder.ondataavailable = e => console.log(URL.createObjectURL(e.data));
   recorder.start();
   setTimeout(_ => recorder.stop(), 30000);
});

Dale Curtis

unread,
Jun 27, 2022, 1:05:08 PM6/27/22
to guest271314, media-dev
Thanks for the report. Can you run bisect-builds.py to see when it regressed?


- dale



--
You received this message because you are subscribed to the Google Groups "media-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to media-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/media-dev/89bf41d3-f09a-4fc8-af33-359e4a93d609n%40chromium.org.

guest271314

unread,
Jun 27, 2022, 10:20:03 PM6/27/22
to media-dev, Dale Curtis, media-dev, guest271314
Got an error message that Blob links are blocked for the Blob URL in the code.

Is there a way to enable Blob links on New Tab page during bisect?

guest271314

unread,
Jun 27, 2022, 11:23:54 PM6/27/22
to media-dev, guest271314, Dale Curtis, media-dev
Note, bisect-tools.py shebang line points to python alone. Python 2x is deprecated and on *nix the binary can point to python3, not the generic python comman without the user adjusting the default install of Python 3x, e.g.,

$ python -h

Command 'python' not found, did you mean:

  command 'python3' from deb python3
  command 'python' from deb python-is-python3

I ran 

$ ./bisect-builds.py -a linux64 -g M102 -b M103 --use-local-cache --verify-range -- --no-first-run --password-store=basic --user-data-dir=/tmp http://localhost:8000/index.html
Scanning from 992738 to 1002911 (10173 revisions).
Downloading list of known revisions...
Loaded revisions 41523-1018503 from /home/user/.bisect-builds-cache.json
Downloading revision 992740...
Received 154342263 of 154342263 bytes, 100.00%
Trying revision 992740...
Revision 992740 is [(g)ood/(b)ad/(r)etry/(u)nknown/(s)tdout/(q)uit]: g
Downloading revision 1002910...
Trying revision 1002910...
Revision 1002910 is [(g)ood/(b)ad/(r)etry/(u)nknown/(s)tdout/(q)uit]: g
Unexpected result at a range boundary! Your range is not correct.
Cleaning up...

Both versions work as expected. 

I attached the 30 second WebM audio recordings (103 doesn't start playback until around 13 seconds because I hadn't began system audio output yet, still captures when I did start audio output). I also attached the result from 

Chromium 105.0.5134.0 (Developer Build) (64-bit) 
Revision f66af87481a6c26c1e862914ad5fd7e47962a4b9-refs/heads/main@{#1016058}
OS Linux JavaScript V8 10.5.42


I also tested on Firefox 101, which also records audio.

Poor quality capturing remapped source using getUserMedia() for the 30 second recording from M102, M103, which from https://chromereleases.googleblog.com/2022/06/stable-channel-update-for-desktop_21.html M103 is stable release and I didn't find a way to bisect developer builds using bisect-builds.py.

I wrote https://github.com/guest271314/captureSystemAudio/tree/master/native_messaging/capture_system_audio to workaround Chromium not supporting speech synthesis audio output, or entire system audio output capture (see also 1136480 ). Users of Discord, et al also used the pactl null-sink or remap-source code to achieve other requirements https://github.com/edisionnano/Screenshare-with-audio-on-Discord-with-Linux
M102.webm
Firefox-101.0.1.ogx
M105.webm
M103.webm

guest271314

unread,
Jun 28, 2022, 2:07:50 AM6/28/22
to media-dev, guest271314, Dale Curtis, media-dev
I have several Chromium launch flags set. 

I began testing with and without AudioServiceOutOfProcess first.

To test I launched with --user-data-dir=/home/user/test, where I do not ordinarily use --user-data-dir flag, with AudioServiceOutOfProcess flag removed.

MediaRecorder captured audio to a WebM blob.

For completeness, I re-included AudioServiceOutOfProcess flag, where the only addition was --user-data-dir=/home/user/test.

MediaRecorder captured audio to a WebM blob.

Therefore the issue is that MediaRecorder records silence for this case when --user-data-dir flag is not used.

Any idea why not setting --user-data-dir flag results in MediaRecorder recording a blip of audio then silence? 


M105-dev-with-user-data-dir.webm
M105-dev-without-user-data-dir-flag.webm

Dale Curtis

unread,
Jun 28, 2022, 1:22:08 PM6/28/22
to guest271314, media-dev
That would seem to imply some extension or experiment is causing issues. You can try: https://chromium.googlesource.com/chromium/src/+/HEAD/tools/variations/bisect_variations.py with the variations cmd from the broken build and see if that yields results. It's a bit brittle though.

- dale

guest271314

unread,
Jul 25, 2022, 1:39:54 AM7/25/22
to media-dev, dalec...@chromium.org, media-dev, guest271314
I think the problem is getUserMedia(): When echoCancellation is set to true and channelCount is not explicitly set to 2, respectively, channelCount of audio MediaStreamTrack will always be 1. Related: When channelCount is set to 2 and echoCancellation is set to true, only silence is captured by MediaRecorder. Explicitly set channelCount to 2, echoCancellation to false in audio constraints to capture 2 channels, when available. See https://bugs.chromium.org/p/chromium/issues/detail?id=453876#c5.
Reply all
Reply to author
Forward
0 new messages