在Docker中使用vlc访问主机网络摄像头

时间:2014-09-09 20:19:03

标签: video docker vlc

我正在尝试为流媒体服务器设置Docker容器,但是当我尝试从容器内访问主机的网络摄像头时,我遇到了麻烦。

我使用以下命令运行容器:docker run -t -i --privileged --rm my/image /bin/bash。 VLC拒绝以root身份运行,因此我在Dockerfile中创建了一个新用户。

以下是我用来测试网络摄像头是否正常工作的命令: cvlc v4l2:///dev/video2:chroma=h264 --sout '#std{access=file,mux=ps,dst=test.h264}'。一切都在主机上按预期工作。

当我尝试在容器中运行命令时,我看到以下内容:

[0x7fc300003108] mux_ps mux: Open
[0x7fc300003108] main mux debug: using sout mux module "mux_ps"
[0x7fc300000b78] main stream output debug: muxer support adding stream at any time
[0x7fc300000b78] main stream output debug: muxer prefers to wait for all ES before starting to mux
[0x7fc300000f48] stream_out_standard stream out debug: using `file/ps://test.mp4'
[0x7fc300000f48] main stream out debug: using sout stream module "stream_out_standard"
[0x7fc308000ab8] main input debug: using timeshift granularity of 50 MiB, in path '/tmp'
[0x7fc308000ab8] main input debug: `v4l2:///dev/video2:chroma=h264' gives access `v4l2' demux `' path `/dev/video2:chroma=h264'
[0x7fc308000ab8] main input debug: creating demux: access='v4l2' demux='' location='/dev/video2:chroma=h264' file='/dev/video2:chroma=h264'
[0x7fc300004088] main demux debug: looking for access_demux module matching "v4l2": 20 candidates
[0x7fc300004088] v4l2 demux debug: opening device '/dev/video2'
[0x7fc300004088] v4l2 demux error: cannot open device '/dev/video2': Permission denied
[0x7fc300004088] v4l2 demux debug: opening device '/dev/video2'
[0x7fc300004088] v4l2 demux error: cannot open device '/dev/video2': Permission denied
[0x7fc300004088] main demux debug: no access_demux modules matched
[0x7fc308000ab8] main input debug: creating access 'v4l2' location='/dev/video2:chroma=h264', path='/dev/video2:chroma=h264'
[0x7fc300005988] main access debug: looking for access module matching "v4l2": 25 candidates
[0x7fc300005988] v4l2 access debug: opening device '/dev/video2'
[0x7fc300005988] v4l2 access error: cannot open device '/dev/video2': Permission denied
[0x7fc300005988] main access debug: no access modules matched
[0x7fc308000ab8] main input error: open of `v4l2:///dev/video2:chroma=h264' failed
[0x7fc308000ab8] main input error: Your input can't be opened
[0x7fc308000ab8] main input error: VLC is unable to open the MRL 'v4l2:///dev/video2:chroma=h264'. Check the log for details.
[0x927218] main playlist debug: dead input

当我尝试运行类似ffmpeg的类似工具时,我看到相同的权限被拒绝消息。关于我可能出错的地方的任何暗示?

1 个答案:

答案 0 :(得分:1)

问题是我的用户不属于video组。此外,我必须将视频设备的权限更改为root.video

此处提供更多信息:http://www.tldp.org/HOWTO/html_single/Webcam-HOWTO/#PERMISSIONS