0

I'm using v4l2loopback to create 2 virtual cameras that I can then stream an mp4 into and simultaneously read from those cameras with a gstreamer pipeline as if the mp4 was the video being recorded by those virtual cameras.

My gstreamer pipeline

videomixer name=mix sink_0::xpos=0 sink_0::ypos=0 ! tee name=t ! videorate ! videoscale ! videoconvert ! video/x-raw,framerate=3/1,format=RGB,height=240,width=320 ! filesink location=/tmp/realtime_ai_video t. ! x264enc name=h264enc tune=zerolatency ! video/x-h264,stream-format=avc,alignment=au ! queue !  appsink name=mp4_appsink enable-last-sample=true emit-signals=true sync=false drop=false v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg,height=240,width=320,framerate=3/1 ! jpegparse ! jpegdec !  video/x-raw,format=I420 ! mix.sink_0

The command I'm using to create the virtual cameras

sudo modprobe v4l2loopback devices=2 card_label="Loopback-1,Loopback-2"

The commands I'm using to stream the mp4 into the virtual cameras

ffmpeg -re -i r4.mp4 -map 0:v -f v4l2 /dev/video0
ffmpeg -re -i r4.mp4 -map 0:v -f v4l2 /dev/video1

The errors I get from gstreamer when running the pipeline to read from the virtual cameras

#033[33m13772#033[00m 0x560d53aeca40 #033[33;01mWARN   #033[00m #033[00m             basesrc gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0>#033[00m error: Internal data stream error.
#033[33m13772#033[00m 0x560d53aeca40 #033[33;01mWARN   #033[00m #033[00m             basesrc gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0>#033[00m error: streaming stopped, reason not-negotiated (-4)
ERROR:store.cameras.ringbuffer_camera_writer:gst-stream-error-quark: Internal data stream error. (1) | ../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0
  • v4l2: v0.12.7
  • GStreamer: 1.20.3
  • ffmpeg: 4.4.2-0ubuntu0.22.04.1
  • OS: Ubuntu 22.04 jammy

The stipulation is that I'd like not to change the pipeline command unless it's a small addition or difference, I'm wanting to exhaust any other possibility for instance with ffmpeg or v4l2loopback before editing the pipeline.

1 Answer 1

0
sudo modprobe v4l2loopback devices=1 exclusive_caps=0 card_label="loopback-1"
v4l2loopback set-fps 3 /dev/video2
ffmpeg -re -i r4.mp4 -s 320x240 -c:v mjpeg -pix_fmt yuvj420p -aspect 1:1 -r 3 -f v4l2 /dev/video2
... and repeat for second camera

I had to match the caps required by v4l2src

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .