简体   繁体   English

Linux作为USB UVC设备

[英]Linux as a USB UVC device

What is needed for making a Linux device (Raspberry Pi) behave like a UVC device for another computer? 使Linux设备(Raspberry Pi)的行为类似于另一台计算机的UVC设备需要什么? Essentially, I would like to use output from ffmpeg to behave like a webcam input for another computer. 基本上,我想使用ffmpeg的输出来表现得像另一台计算机的网络摄像头输入。

What is needed for making a Linux device (Raspberry Pi) behave like a UVC device for another computer? 使Linux设备(Raspberry Pi)的行为类似于另一台计算机的UVC设备需要什么?

This can actually be done on the Pi Zero without a custom kernel. 这实际上可以在没有自定义内核的Pi Zero上完成。 After setting dtoverlay=dwc2 in your config.txt for OTG support, reboot and run: 在config.txt中设置dtoverlay=dwc2以获得OTG支持后,重新启动并运行:

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. 这些是通过流式传输合成数据使您的Pi充当网络摄像头的第一步,您可以在Skype,FaceTime或其他网络摄像头查看器中测试这些数据。 Here is source for the uvc-gadget userspace program with its commonly recommended patches. 以下是uvc-gadget用户空间程序的源代码及其通常推荐的补丁程序。

Essentially, I would like to use output from ffmpeg to behave like a webcam input for another computer. 基本上,我想使用ffmpeg的输出来表现得像另一台计算机的网络摄像头输入。

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 . 现有的uvc-gadget程序可以播放通过GStreamer播放的网络摄像头录像,在这篇文章对此进行了更多的讨论。 For arbitrary input to FFmpeg, you may have to integrate your own output plugin code with uvc-gadget. 对于FFmpeg的任意输入,您可能必须将自己的输出插件代码与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. 如果你使用压缩:注意FFmpeg已经可以输出各种容器格式的mjpeg,但是这些数据仍然必须转换为UVC有效负载mjpeg格式。

You will roughly need an USB OTG capable RPi, the RPi 3 is not capable of that. 你将大致需要一个支持USB OTG的RPi,RPi 3无法做到这一点。 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. 然后你需要一个模拟真实设备的UVC驱动程序的自定义内核驱动程序,我不知道任何直接执行此操作的项目。

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. 我能想到的最简单的方法是通过RTMP流式传输录制的图像,而不是试图模拟UVC,因为这不是一个小小的壮举。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM