首页 > 解决方案 > 下沉到虚拟 v4l2 设备

问题描述

我在 Ubuntu 19.04 上试过一个例子

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

但是 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 ...

为什么它不起作用?我在文档中没有找到这个,我需要以某种方式创建 /dev/video10 吗?

我对默认设备 /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 ...

预先感谢。

标签: linuxgstreamer

解决方案


您的问题标题表明您想写入虚拟视频设备。v4l2 设备既可以是输入视频设备,也可以是输出视频设备。您的相机是视频输入(捕捉)设备。在 gstreamer 中引导 v4l2sink(因此是管道的端点)可能会失败。

但是,您可以生成虚拟输出设备。您正在寻找的是类似v4l2-loopback设备的东西。它允许您生成这样的虚拟/dev/video10设备:

modprobe v4l2loopback video_nr=10

推荐阅读