3

I am using v4l2loopback v0.12.5 and wf-recorder to record my screen on wayland. I am looking to reduce the framerate of the video stream as read by my browser. Currently I am unable to get anything other than 60fps.

I have used version wf-recorder 0.2.1 and this fork as it adds the option to set the framerate. However, I get the same output.

If I start wf-recorder with this command:

wf-recorder \
        -x yuv420p \
        -g "$x,$y ${width}x$height" \
        --muxer=v4l2 \
        --codec=rawvideo \
        --file="$device"

/sys/devices/virtual/video4linux/video0/format looks like this:

YU12:2560x1440@30

However the command output reports that the framerate is 60 not @30:

selected region 0 0 2560 1440
Framerate: 60
Choosing pixel format yuv420p
Output #0, video4linux2,v4l2, to '/dev/video0':
    Stream #0:0: Unknown: none (rawvideo)

If I open the device with ffplay I see that it reports 30fps:

Input #0, video4linux2,v4l2, from '/dev/video0':B sq=    0B f=0/0
  Duration: N/A, start: 1102.869115, bitrate: 1327104 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 2560x1440, 1327104 kb/s, 30 fps

Using webcamtests.com I get ~60fps reported.

If I instead start wf-recorder with the -r flag set to 6:

wf-recorder \
        -x yuv420p \
        -r 6 \
        -g "$x,$y ${width}x$height" \
        --muxer=v4l2 \
        --codec=rawvideo \
        --file="$device"

wf-recorder reports Framerate: 6 however /sys/devices/virtual/video4linux/video0/format still shows YU12:2560x1440@30.

This leads me to believe that the issue is not with wf-recorder, or rather that I can't set the framerate with that tool.

Instead I looked to change the settings on the device. Running:

echo "@6"| sudo tee /sys/devices/virtual/video4linux/video0/format

I see the format change to YU12:2560x1440@6. However, I see no change in the perceived framerate.

If I run:

sudo v4l2-ctl -d /dev/video0 -p 6

I see the format change to: YU12:2560x1440@6000/1000 but again I see no change in the perceived framerate (still 60fps in my browser).

There don't seem to be any options to set for this on the v4l2loopback kernel module.

I'm running out of ideas - anything else to try or is my poor computer doomed to processes 100Mbit video streams forever? :D

Charlie Egan
  • 141
  • 1
  • 5

2 Answers2

1

In the end I was able to do this with another v4l device and this gstreamer command:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! videorate drop-only=true ! video/x-raw,framerate=6/1 ! v4l2sink device=/dev/video1
Charlie Egan
  • 141
  • 1
  • 5
  • Did you see a performance improvement with this approach, or less resource usage? – JinnKo Mar 10 '21 at 11:31
  • I can’t remember I’m afraid. Shortly after I read about pipewire and how to enable that which solved my screen sharing issues in google meet. https://wiki.archlinux.org/index.php/PipeWire – Charlie Egan Mar 11 '21 at 13:14
  • The `videorate` control doesn't change anything in the source. It simply drops/duplicates incoming frames to match the requested rate. This will give you the output you require, but it doesn't reconfigure your camera. – David C. Sep 23 '22 at 14:09
1

I was able to limit the frames per second to 10 by setting it on the v4l2loopback device like this before launching wf-recorder.

v4l2-ctl -d /dev/video6 --set-parm 10

Playing the stream with ffplay /dev/video6 after doing this confirmed the setting:

Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 2560x1410, 433152 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc

The help output of v4l2-ctl has the following about this setting:

$ v4l2-ctl --help-all
...
  -P, --get-parm     display video parameters [VIDIOC_G_PARM]
  -p, --set-parm <fps>
                     set video framerate in <fps> [VIDIOC_S_PARM]
...
JinnKo
  • 156
  • 3