umlaeute / v4l2loopback

v4l2-loopback device
GNU General Public License v2.0
3.67k stars 523 forks source link

set-caps question #198

Open ROBERT-MCDOWELL opened 5 years ago

ROBERT-MCDOWELL commented 5 years ago

I just created a video device with

$ sudo modprobe v4l2loopback devices=1 exclusive_caps=1 video_nr=1card_label=mysink

tried to set it like this

$ sudo v4l2loopback-ctl set-caps "video/x-raw,format=yuv, width=640, height=480" /dev/video1

but I get

WARNING: erroneous pipeline: could not link videotestsrc0 to v4l2sink0, neither element can handle caps video/x-raw, format=(string)yuv, width=(int)640, height=(int)480
output to /dev/video1 failed

any idea? thanks

ROBERT-MCDOWELL commented 5 years ago

machine info: Fedora 27 64bits kernel 4.19.1-rt3 v4l2loopback version: 0.12.0

umlaeute commented 5 years ago

that doesn't seem to be a valid gstreamer-1.0 caps-string, the format yuv does not exist.

try something like UYVY instead.

ROBERT-MCDOWELL commented 5 years ago

ok thanks now I get

$ v4l2loopback-ctl set-caps "video/x-raw,format=UYVY, width=640, height=480" /dev/video1
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(642): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x85208000
Setting pipeline to NULL ...
Freeing pipeline ...
output to /dev/video1 failed
lynn901213 commented 4 years ago

Is it possible for v4l2loopback device to accept mjpeg as input? I tried to set caps like v4l2loopback-ctl set-caps "image/jpeg, width=1280, height=720, fps=30/1" /dev/video1 where /dev/video1 is my v4l2loopback device. It seems like it is using gstreamer videotestsrc as the pipeline video src for setting the caps, and gst-inspect-1.0 videotestsrc shows videotestsrc only accepts paddings as video/x-raw. My question here would be, can we set mjpeg as the format for v4l2loopback device?

umlaeute commented 4 years ago

sure. you can. the current behaviour simply a limitation of the v4l2loopback-ctl script (or rather, as you noted, the underlying videotestsrc element).

you can manually change the output-format by running a pipeline like:

gst-launch-1.0 videotestsrc num-buffers=1 ! "video/x-raw, width=1280, height=720, fps=30/1" ! avenc_mjpeg ! v4l2sink device=/dev/video1
nicola-sorace commented 3 years ago

I'm getting the same error as @ROBERT-MCDOWELL above:

$ sudo v4l2loopback-ctl set-caps "video/x-raw,format=UYVY, width=1920, height=1200" /dev/video0
Setting pipeline to PAUSED ...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Device '/dev/video0' is not a output device.
Additional debug info:
../gst-plugins-good/sys/v4l2/v4l2_calls.c(636): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x5208000
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...
output to /dev/video0 failed

Edit: Looks like this was solved by removing the exclusive_caps=1 option when starting the v4l2loopback kernel module.

103sbavert commented 7 months ago

I'm getting the same error as @ROBERT-MCDOWELL above:

$ sudo v4l2loopback-ctl set-caps "video/x-raw,format=UYVY, width=1920, height=1200" /dev/video0
Setting pipeline to PAUSED ...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Device '/dev/video0' is not a output device.
Additional debug info:
../gst-plugins-good/sys/v4l2/v4l2_calls.c(636): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x5208000
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...
output to /dev/video0 failed

Edit: Looks like this was solved by removing the exclusive_caps=1 option when starting the v4l2loopback kernel module.

Is there a way to prevent this behavior without removing that option? I need that option for Discord and Chrome.