v4l2loopback resolution: How to store configuration across reboots?

tl;dr
I cannot figure out how to get the v4l2loopback resolution configuration to persist across reboots (width=1280, height=720).
The openSUSE repository version of droidcam does not respect the /etc/modprobe.d/droidcam.conf, and v4l2loopback-ctl needs to be run (or left running) anytime I want to use droidcam.

Background:
after zypper in droidcam{,-cli} and a reboot:
Several modules need to be initialized/configured prior to running droidcam.
I was able to set videodev, v4l2loopback, snd-aloop to run automatically at boot using /etc/modules_load.d/droidcam.conf & /etc/modprobe.d/droidcam.conf, but was unable to get the v4l2loopback resolution to stick.

Instead, I created a script of commands that starts & configures all of the necessary modules, but leaves a process active in the terminal, so I have to open another terminal to run droidcam separately.

This doesn’t seem right. Surely there is a simple way to permanently store the v4l2loopback configuration, so that it does not need to be left running whenever I want to use droidcam.
What am I missing?

Works, but v4l2loopback-ctl command needs to be run (or left running) for droidcam use. Does not store settings:

#!/bin/bash -x 
 
sudo modprobe videodev 
sudo modprobe v4l2loopback video_nr=9 devices=1 card_label="Droidcam" 
sudo modprobe snd-aloop index=2 
v4l2loopback-ctl set-caps "video/x-raw, format=I420, width=1280, height=720" /dev/video9 

Works, but without v4l2loopback resolution configuration:
/etc/modules_load.d/droidcam.conf

videodev 
v4l2loopback 
snd-aloop 

/etc/modprobe.d/droidcam.conf


options v4l2loopback width=1280 height=720 
options snd-aloop index=2

Any assistance is appreciated,
-Cyril

For a proper solution,
I’d guess you’d have to talk to the app devs… Only they know how they wrote their kernel module.

In the meantime,
Maybe the following time honored workaround is good enough or you…
If you want anything to run late in the bootup process (you’d want this), then you can place a line in the following file that invokes your configurations script

/etc/sysctl.conf

Should work.

TSU

HUH? That file should not be touched, it’s for sys settings, nothing to do with module loading?

Hi
Create a oneshot systemd service file in /etc/systemd/system to call your script as your module an options are being set at boot.


# /etc/systemd/system/v4l2loopback.service
#

[Unit]
Description=Run v4l2loopback-ctl command for droidcam use.
After=network.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c "/path/to/script.name"

[Install]
WantedBy=graphical.target

Regardless what the sysctl.conf file is normally used for,
The fact that it works by re-writing values and not used to modify the original system values makes it work for other uses if one chooses.
Yes, it may more normally be used for modifying /proc values, but it isn’t restricted to doing only that… It’s possible to embed any command you want and it will be executed when the file is read.

I don’t see it’s any different whether a systemd service is created that invokes the custom startup scripts compared to invoked some other way although a systemd service is more consistent thematically running on a systemd system.

I suppose how one evaluates this is whether one is of the school of doing things only according to the original rules vs doing things because they work without risk although not by the original rules.

TSU

Hello, Cyril.
Please make sure that “width” and “height” are valid options of the “v4l2loopback” kernel module. Right now they look to me as “v4l2loopback-ctl” parameters only.
If YES, then you still failed to follow the documentation properly:GitHub - umlaeute/v4l2loopback: v4l2-loopback device

  1. Specify only one option per line
  2. Update the initramfs image with “sudo dracut -f” before the values you set take effect at the boot time.