This is cracking - thanks a lot! Works great with Module 3 on Bookworm.I'm using the camera 2 module, but my workaround (for chromium, it does not work with firefox) should work for the module 3 too. Might need to change resolution and pixelformat if module 3 can't output YUY2, but I cannot confirm this until I get the latest camera myself. Basically I use gstreamer to pipe raw camera output to virtual camera device on v4l2loopback, it introduces a small overhead of course and chromium doesn't have access to camera controls which you need to manipulate via the pipeline, but otherwise this works really well for me.
I have tested this method with fresh install on Raspberry Pi 4, with camera module 2 and Raspberry Pi OS 64-bit 10 Oct. release:
Steps for my workaround:
install gstreamer and necessary plugins:Install the loopback (this can fail if you upgraded the kernel because of headers mismatch)Code:
sudo apt-get install -y gstreamer1.0-tools gstreamer1.0-plugins gstreamer1.0-libcamera
Activate the loopback module on startup:Code:
sudo apt-get install -y v4l2loopback-dkms
paste this into the file and save:Code:
sudo nano /etc/modules-load.d/v4l2loopback.conf
Configure the virtual camera device:Code:
v4l2loopback
and paste the following content inside:Code:
sudo nano /etc/modprobe.d/v4l2loopback.conf
Make sure the video_nr= doesn't collide with any video devices already present, check this withCode:
options v4l2loopback video_nr=8options v4l2loopback card_label="Chromium device"options v4l2loopback exclusive_caps=1
If there's video8 already present, pick another number.Code:
ls /dev/
Now reboot and start gstreamer pipeline:This command needs to be running when you use the camera with the browser , either do it manually or set it to boot with the system by crontab or any other method.Code:
gst-launch-1.0 libcamerasrc ! "video/x-raw,width=1280,height=1080,format=YUY2",interlace-mode=progressive ! videoconvert ! v4l2sink device=/dev/video8
Afterwards chromium should see this as a normal camera it can access, I use https://webrtc.github.io/samples/src/co ... esolution/ to verify. Gstreamer will complain about lack of queues, but I didn't notice any hiccups in the stream and it crashes after I add them.
If this pipeline fails, there's a safer one that should be more universal if module 3 cannot run with the same settings:It puts more CPU strain on the videoconvert element as it will also have to handle pixel format conversion on the fly, but it should still be manageable.Code:
gst-launch-1.0 libcamerasrc ! "video/x-raw,width=1280,height=1080" ! videoconvert ! v4l2sink device=/dev/video8
You can of course set a higher resolution, 1280x1080 is just the one I use.
Statistics: Posted by czarop — Wed Jan 24, 2024 7:25 pm