Use phone camera for linux desktop (2023)
I've moved to Fedora Linux and new mjpeg streaming app was released, since the previous article was written. So, because I needed a camera again, I decided to update this manual.
First of all, there is a new app by Thomas SIMON: RemoteCam. It directly streams video from camera and permits multiple settings like video resolution and jpeg quality.
To create a dummy camera interface on Fedora, we need to install v4l2loopback packet:
sudo dnf install v4l2loopback
Next, after reboot, we're ready to start the stream with ffmpeg:
sudo ffmpeg -f mjpeg -r 5 -i "http://<Phone IP>:8080/cam.mjpeg?fps=10" -r 10 -pix_fmt yuv420p -f v4l2 /dev/video0
My Wi-Fi connection speed was enough for such stream. But it is still possible to use it with adb port forwarding over usb:
adb forward tcp:8080 tcp:8080