Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux as a USB UVC device

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.

like image 836
frodeborli Avatar asked Oct 29 '22 10:10

frodeborli


1 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.

like image 174
jdonald Avatar answered Nov 15 '22 06:11

jdonald