- Rust 100%
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
gphoto2-to-v4l2
This app uses gphoto2 for capturing preview images from any supported camera, and streams it to a
gstreamer pipeline for decoding and sending it to a v4l2loopback camera device.
How does it work
First you will need to create a v4l2loopback device by loading the corresponding kernel module:
sudo modprobe v4l2loopback
Then plug in your camera via USB, and run this app:
cargo run
How to adapt to your need
Since it is using gstreamer, you can modify the pipeline as you like, it should work.
My camera is not showing in gphoto2
See if you have Wi-Fi enabled on your camera, and disable it, some of them refuse to communicate both by USB AND Wi-Fi.
Why yet another app like this
I'm pretty sure there are better ways of doing it, but first I found only 2 solutions, one which uses their own implementation of things like color space conversion, which can be ok but hey why not using optimised libraries for this ? And the second is the "cli" way, of sending gphoto2 raw output to either ffmpeg or a gst-launch pipeline, which 1 makes it less performant because of IO, and 2 makes it difficult to nicely close the gphoto2 connexion, leading to an invalid state of my camera (EOS 2000D) which forces me to always reboot it after using the script.
References:
What's next
I did not manage to make it work through pipewire, but I think it's because I don't yet understand
how pipewire streams capabilities are communicated. Using pipewire would allow me to get rid of
v4l2loopback, since it is a bit annoying to rely on a kernel module to be loaded manualy.