I am trying to control the input to a WebRTC web application running on Chrome, controlled by Selenium, inside a Docker container.

This is part of an automated test of the WebRTC application.

As part of the testing, I want to send controlled audio and (preferably controlled) video into the Chrome running in Docker.

I already have controllable audio input using a fake audio device, but using that means that I have a "real" microphone in Chrome, and can't use its fake device functionality to emulate video input.
Chrome's --use-file-for-fake-audio-capture feature function only works if --use-fake-device-for-media-stream is also active, which will disable access to the system's microphone input.


I need a way to emulate a webcam in such a way that it can be used in Chrome for a WebRTC video call, all inside a Docker container.
Ideally, I should also be able to control the picture in that fake webcam.

I've come across several posts where people have successfully got Docker containers to use webcam devices (including fake ones) on the host system, but that's a mapping to a single device on the host, and I want to be able to run multiple Docker containers (20+) on the same host, each with its own unique webcam device.

The standard way to do this seems to be using the v4l2loopback driver, but that is a kernel module, and Docker uses the host's kernel and so cannot load its own modules inside containers.

In theory it would be possible to create multiple fake webcam devices on the hosts and then map each of those to a Docker container, though that would be a logistical nightmare (the test would need to control the cameras on the host, rather than talking to the containers), and v4l2loopback is limited to 8 devices in any case (again, theoretically I could recompile the driver to support more.)

It seems that what I'm really looking for is some way to fake a webcam device in user space instead of kernel space.
I did find a userspace webcam driver called UV4L, but it's for the Raspberry Pi (ARM architecture.)


Does anyone know a way that I could control video into Chrome's capture device inside a Docker container, either using a fake capture device in userspace, or through some other means?

  • Any update on this one? – MoShe Jun 5 '18 at 23:20

Thank you for the great post about emulating audio input. Regarding webcam, have you tried the following Chrome option: --use-file-for-fake-video-capture


  • I have, and it's the only way I've found to test video so far. Unfortunately, you have to use both fake audio and fake video if you use either, so by using the fake video input, I lose the ability to control the audio input. – Nameless Voice Oct 9 '17 at 16:48

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.