I’ve encountered this issue before on Linux systems. One thing to check is your system’s graphics drivers. Outdated or incompatible drivers can cause problems with the MediaRecorder API.
Try updating your graphics drivers to the latest version. If you’re using NVIDIA, you might need to switch to the proprietary drivers instead of the open-source ones.
Another potential solution is to use a different method for screen capture on Linux. Instead of getDisplayMedia, you could try using the desktopCapturer API from Electron. It tends to be more reliable on Linux systems.
Lastly, make sure you’re running Puppeteer with the necessary permissions. Sometimes, Linux security settings can block access to screen recording features. You might need to modify your user permissions or run the script with sudo.
If all else fails, consider using a native screen recording tool like SimpleScreenRecorder and controlling it via shell commands from your Node.js script. It’s a bit of a workaround, but it can be more reliable on Linux systems.
Hey there! I’ve run into similar issues with screen recording on Linux using Puppeteer. It can be a real pain, especially when it works fine on other platforms.
One thing that helped me was making sure I had the right dependencies installed. On Ubuntu, you might need to install some additional packages like libgbm-dev and xvfb. Try running:
sudo apt-get install libgbm-dev xvfb
Then, launch Puppeteer with Xvfb:
xvfb-run node your-script.js
This creates a virtual framebuffer, which can sometimes trick the system into allowing screen capture.
Another trick that worked for me was running Chrome in headless mode with the --headless=new flag. It seems to handle media APIs better in some cases.
If none of that works, you might want to look into using ffmpeg for screen recording instead. It’s a bit more involved to set up, but it’s rock-solid on Linux systems.
Hope this helps! Let me know if you need any more details.
yo, had the same prob on my ubuntu box. try runnin puppeteer with --no-sandbox --disable-setuid-sandbox flags. Also, make sure ur chromium is up to date. if that dont work, u might need to mess with ur X server settings or use Wayland. Good luck man!