Public bug reported:

Title: v4l2-relayd with libcamerasrc input: caps in VIDEOSRC crash the
input pipeline, frames dropped unless sync=false, copied V4L2 timestamps
stall PipeWire consumers

I tried yesterday to have my ipu7 virtual camera working. With the help
of many web sites and Claude Opus 5.5. After a while and spotting a few
issues (package missing, bug in libcamera relative to the resolution [cf
my comment in Bug #2172303], "we" isolated what seems to be a bug
relative to the way the timestamps are handled in PipeWire with
sync=false in V4L2 (without this, frames are dropped, up to less than
3-4FPS). I copy-paste the "report" suggested by Claude AI.

Context: Dell Pro 13 Premium (IPU7, OV08X40), Ubuntu 26.04, v4l2-relayd 
0.2.0-0ubuntu1. The camera only works through libcamera (see libcamera bug 
#2172303, comment), so v4l2-relayd is used to expose it as a v4l2loopback 
device (exclusive_caps=1 max_buffers=8 card_label="Virtual Camera") with:
  VIDEOSRC="libcamerasrc ! capsfilter caps=video/x-raw,width=3840,height=2160 ! 
queue max-size-buffers=2 leaky=downstream ! videoconvertscale n-threads=8 ! 
videorate"
  FORMAT=YUY2 WIDTH=1280 HEIGHT=720 FRAMERATE=30/1

1. Bare caps in VIDEOSRC (e.g. "... ! 
video/x-raw,format=YUY2,width=1280,height=720,framerate=30/1") make the input 
pipeline fail when a client connects:
   ERROR GST_PIPELINE grammar.y: no element "video"
   ERROR V4L2_RELAYD src/v4l2-relayd.c:199:backend_pipeline_create: no element 
"video"
   GStreamer-CRITICAL: gst_element_set_state: assertion 'GST_IS_ELEMENT 
(element)' failed
   The daemon keeps running and the client gets a black picture. The same 
description works with gst-launch-1.0; "capsfilter caps=..." works around it.

2. With the default output pipeline, v4l2sink drops most frames ("A lot
of buffers are being dropped... There may be a timestamping problem"):
3-4 fps. Adding sync=false to v4l2sink gives 30 fps, but requires
overriding ExecStart because the output pipeline is hard-coded in
[email protected].

3. With sync=false, buffers are queued with GStreamer PTS copied as V4L2 
timestamps (v4l2-ctl shows "ts-copy"), not CLOCK_MONOTONIC. Consumers that 
apply their own timestamps work:
   - GStreamer v4l2src: steady 30 fps;
   - Firefox (WebRTC, direct V4L2, media.webrtc.camera.allow-pipewire=false): 
works, but the picture stays black for 5-10 seconds each time the camera is 
(re)started (not yet determined whether this is the relay start-up or the 
software ISP auto-exposure converging).
   PipeWire, however, uses the v4l2loopback node as graph driver: with 
pipewiresrc / GNOME Snapshot the picture is smooth for a few seconds, then 
degrades and freezes (0.15-3 fps), even with sync=false on the consumer sink.
   Suspected cause: non-monotonic timestamps that restart at 0 whenever the 
input pipeline restarts.
   - Zoom (direct V4L2): works after the same start-up delay, but toggling 
background blur (Zoom then closes and reopens the device several times) leaves 
it with no picture, or only occasional frames, for more than a minute. The 
relay log shows libcamera restarting cleanly at each reopen (new CameraManager, 
3840x2160 configured within ~20 ms, no error), so frames are likely to be 
produced but discarded by the consumer, consistent with timestamps restarting 
at 0 on every input-pipeline restart.

4. io-mode=rw on v4l2sink (so that v4l2loopback stamps buffers itself)
leaves the device as "Video Output" only with exclusive_caps=1, so
consumers see no camera.

Expected: v4l2-relayd emits correctly timestamped frames (e.g.
CLOCK_MONOTONIC-based) so that libcamerasrc can be used as input, which
is needed for IPU7 laptops whose camera is only supported through
libcamera.

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "part of log file of v4l2-relayd"
   
https://bugs.launchpad.net/bugs/2172582/+attachment/6013673/+files/relayd-B.log

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2172582

Title:
  Title: v4l2-relayd with libcamerasrc input: caps in VIDEOSRC crash the
  input pipeline, frames dropped unless sync=false, copied V4L2
  timestamps stall PipeWire consumers

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2172582/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to