Screen recording fails on Ubuntu: MediaRecorder API throws NotReadableError

I’m stuck with a problem on Ubuntu. My screen recording setup works fine on Windows, but it’s acting up on Linux. Here’s what’s happening:

let displayStream = await navigator.mediaDevices.getDisplayMedia({
  video: {
    screenSource: 'monitor',
    resolution: { width: 1280, height: 720 }
  }
});

let recorder = new MediaRecorder(displayStream);

recorder.ondata = (chunk) => {
  // Handle video chunks here
};

When I run this on Ubuntu, I get:

Error: Can't access display media: NotReadableError

I’ve tried:

  • Using Chrome flags like --use-fake-ui-for-media-stream
  • Setting --auto-select-desktop-capture-source=Entire screen
  • Turning on AudioServiceOutOfProcess
  • Turning off sandbox stuff

Nothing helps. The browser starts up fine, but getDisplayMedia() always fails. Any ideas what could be causing this on Ubuntu?

hey there, had similar issues on ubuntu. have u tried updating ur graphics drivers? sometimes old drivers mess with screen recording. also, check if ur using wayland or x11 display server. wayland can be tricky with screen capture. might be worth switching to x11 temporarily to test. good luck!

I’ve encountered this issue before on Ubuntu. One thing to check is your system’s permissions. Make sure your browser has the necessary permissions to access screen recording. You can do this by going to Settings > Privacy > Screen Recording and ensuring your browser is listed and enabled.

Another potential solution is to use a different Chrome/Chromium-based browser like Brave or Vivaldi. Sometimes these alternatives have better compatibility with Linux systems for screen recording.

If all else fails, you might want to consider using a native Linux screen recording tool like SimpleScreenRecorder or OBS Studio as a workaround. These often have better integration with the Linux desktop environment and might bypass the issues you’re experiencing with the browser-based approach.

I’ve dealt with this exact problem on Ubuntu before. It’s a real pain. One thing that worked for me was tweaking some kernel parameters. Try adding ‘snd-aloop’ to /etc/modules and then run ‘sudo modprobe snd-aloop’. This creates a virtual audio device that sometimes helps with screen recording issues.

Also, check your pulseaudio setup. Run ‘pactl list short sources’ in the terminal and make sure you see your monitor listed as an audio source. If not, you might need to fiddle with pulseaudio configs.

Lastly, if you’re using Wayland, consider logging out and switching to an X11 session. Wayland can be finicky with screen capture. It’s not ideal, but it might get you unstuck until a better solution comes along.

Hope this helps! Let us know if you make any progress.