简体   繁体   English

接收到虚拟 v4l2 设备

[英]Sink to the virtual v4l2 device

I have tried an example on Ubuntu 19.04我在 Ubuntu 19.04 上试过一个例子

gst-launch-1.0 videotestsrc ! v4l2sink device=/dev/video10

But gstreamer fails但是 gstreamer 失败了

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Cannot identify device '/dev/video10'.
Additional debug info:
v4l2_calls.c(609): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
system error: No such file or directory
Setting pipeline to NULL ...
Freeing pipeline ...

Why it doesn't work?为什么它不起作用? I haven't found this in the documentation, do I need to create /dev/video10 somehow?我在文档中没有找到这个,我需要以某种方式创建 /dev/video10 吗?

I did the same for the default device /dev/video1, but it is an input camera device on my laptop:我对默认设备 /dev/video1 做了同样的事情,但它是我笔记本电脑上的输入摄像头设备:

sudo gst-launch-1.0 videotestsrc ! v4l2sink 
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Device '/dev/video1' is not a output device.
Additional debug info:
v4l2_calls.c(639): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x4a00000
Setting pipeline to NULL ...
Freeing pipeline ...

Thank in advance.预先感谢。

The title of your questions suggests you would like to write to a virtual video device.您的问题标题表明您想写入虚拟视频设备。 v4l2 devices can be both input and output video devices. v4l2 设备既可以是输入视频设备,也可以是输出视频设备。 Your camera is a video input (capture) device.您的相机是视频输入(捕获)设备。 Directing a v4l2sink (so an endpoint of the pipeline) in gstreamer will likely fail.在 gstreamer 中引导 v4l2sink(因此是管道的端点)可能会失败。

You can however generate a virtual output device.但是,您可以生成虚拟输出设备。 What you are looking for is something like the v4l2-loopback device.您正在寻找的是类似于v4l2-loopback设备的东西。 It allows you to generate a virtual /dev/video10 device like this:它允许您像这样生成一个虚拟的/dev/video10设备:

modprobe v4l2loopback video_nr=10

Another possible solution for the same error message: recreate the v4l2loopback interface:相同错误消息的另一种可能解决方案:重新创建 v4l2loopback 接口:

sudo rmmod -f v4l2loopback
sudo modprobe v4l2loopback

This might apply to others experiencing the error message from the original question, but who are already aware they need a v4l2loopback device as gstreamer sink.这可能适用于遇到来自原始问题的错误消息的其他人,已经知道他们需要 v4l2loopback 设备作为 gstreamer 接收器。

When trying to stream a video to the existing v4l2loopback device I streamed to using ffmpeg before, I got the same error message尝试将视频流式传输到我之前使用 ffmpeg 流式传输的现有 v4l2loopback 设备时,我收到了相同的错误消息

Device '/dev/video0' is not a output device.设备“/dev/video0”不是输出设备。

Investigation调查

When comparing the state of a working loopback video device and a non-working one (ie after writing to it with ffmpeg) with v4l2-ctl --all -d 0 using diff , I found the following difference :使用diff将工作环回视频设备和非工作环回视频设备的状态(即在使用 ffmpeg 写入后)与v4l2-ctl --all -d 0进行diff ,我发现了以下差异:

--- working     2020-11-19 18:03:52.499440518 +0100
+++ non-working 2020-11-19 18:03:57.472802868 +0100
@@ -3,21 +3,18 @@
         Card type        : GPhoto2 Webcam
         Bus info         : platform:v4l2loopback-000
         Driver version   : 5.9.8
-        Capabilities     : 0x85208002
-                Video Output
+        Capabilities     : 0x85208000
                 Video Memory-to-Memory
                 Read/Write
                 Streaming
                 Extended Pix Format
                 Device Capabilities
-        Device Caps      : 0x05208002
-                Video Output
+        Device Caps      : 0x05208000
                 Video Memory-to-Memory
                 Read/Write
                 Streaming
                 Extended Pix Format
 Priority: 0
-Video output: 0 (loopback in)
 Format Video Output:
         Width/Height      : 960/640
         Pixel Format      : 'YU12' (Planar YUV 4:2:0)

Somehow that "Video Output" capability is required for gstreamer to work successfully and taken away by my previous ffmpeg call.不知何故,gstreamer 需要“视频输出”功能才能成功工作并被我之前的 ffmpeg 调用带走。 The behaviour only occured when I loaded the v4l2loopback module with the exclusive_caps=1 option, see 1 .该行为仅在我使用exclusive_caps=1选项加​​载 v4l2loopback 模块时发生,请参阅1

The solution was to unload / load the v4l2loopback kernel commands, forcefully removing the v4l2loopback kernel module and adding it again using rmmod / modprobe (see above).解决方案是卸载/加载 v4l2loopback 内核命令,强行删除 v4l2loopback 内核模块并使用 rmmod / modprobe(见上文)再次添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM