How to simulate a webcam device

saman01 picture saman01 · Feb 18, 2016 · Viewed 19.2k times · Source

I am working on a project which I need to synthesize a video from existing frames and then format it exactly like a webcam device and make it available to external computers. In other words, this USB output should look exactly as if it was generated by a webcam. Can someone provide some hints about any existing library or any methodology to do this? The target system to create "webcam" output via USB is UBUNTU.

Thanks

Answer

TimSC picture TimSC · Feb 18, 2016

Web cams are usually accessed through a library or the operating system rather than as low level USB devices. In python, one option to read webcam frame is https://github.com/gebart/python-v4l2capture or use my cross platform fork (including windows): https://github.com/TimSC/libvideolive

If you want to create a video stream that is accessible to other computers, you either need to emulate a webcam or an IP camera. A webcam can be emulated on windows by creating a custom media source. https://msdn.microsoft.com/en-us/library/windows/desktop/ms700134%28v=vs.85%29.aspx On linux, you need to stream data to v4l2loopback https://github.com/umlaeute/v4l2loopback. To emulate an IP camera, a good starting point is to base it on the tools available at http://live555.com/