What is needed for making a Linux device (Raspberry Pi) behave like a UVC device for another computer? Essentially, I would like to use output from ffmpeg to behave like a webcam input for another computer.
2 Answers
What is needed for making a Linux device (Raspberry Pi) behave like a UVC device for another computer?
This can actually be done on the Pi Zero without a custom kernel. After setting dtoverlay=dwc2
in your config.txt for OTG support, reboot and run:
sudo modprobe g_webcam
./uvc-gadget -d
These are first steps to make your Pi behave as a webcam by streaming synthetic data, which you can test out in Skype, FaceTime, or other webcam viewers. Here is source for the uvc-gadget userspace program with its commonly recommended patches.
Essentially, I would like to use output from ffmpeg to behave like a webcam input for another computer.
This part could be more involved. The existing uvc-gadget program can supposedly play back webcam recordings captured via GStreamer, more discussion on that in this post. For arbitrary input to FFmpeg, you may have to integrate your own output plugin code with uvc-gadget.
If you go as far as using compression: note FFmpeg can already output mjpeg in various container formats, but that data would still have to be converted to the UVC payload mjpeg format.

- 670
- 7
- 15
You will roughly need an USB OTG capable RPi, the RPi 3 is not capable of that. Then you will need a custom kernel driver that emulates the UVC Driver of a real device, I am not aware of any project that does this directly.
The easiest way I can think of would be to stream the recorded images via RTMP instead of trying to emulate UVC as that is not a small feat.

- 49
- 4