mpromonet / webrtc-streamer

WebRTC streamer for V4L2 capture devices, RTSP sources and Screen Capture
https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/?layout=2x2
The Unlicense
2.94k stars 598 forks source link

Docker container is unable to enumerate local v4l2 devices #663

Closed 12wrigja closed 7 months ago

12wrigja commented 7 months ago

Trying to enumerate v4l2 (/dev/video*) devices bound into the Docker container doesn't work, because the user doesn't have permission to open them.

Specifically, the underlying WebRTC code seems to fail here.

To reproduce:

docker run --device=/dev/video0 -it -p 8000:8000 mpromonet/webrtc-streamer -vvv

Open the webpage, and look at the logs for

[001:743][13] (CapturerFactory.h:90): nb video devices:0

To debug:

docker run --device=/dev/video0 -it --entrypoint="/bin/sh" mpromonet/webrtc-streamer
# Within container
$ groups
user # We are not part of the 'video' group
$ stat /dev/video
  File: /dev/video0
  Size: 0               Blocks: 0          IO Block: 4096   character special file
Device: 63h/99d Inode: 11          Links: 1     Device type: 51,0
# This device is group-owned by 'video', and access is '0660' so not world-owned.
Access: (0660/crw-rw----)  Uid: (    0/    root)   Gid: (   44/   video) 
Access: 2024-02-06 06:29:57.458535512 +0000
Modify: 2024-02-06 06:29:57.458535512 +0000
Change: 2024-02-06 06:29:57.458535512 +0000
 Birth: 2024-02-06 06:29:57.458535512 +0000

I think fixing should be as simple as adding adduser user video to the Dockerfile?