I have a WebRTC solution based on Chromium browsers which uses local device cameras. However the cameras are mounted at a significant distance and cannot be connected to any PC via USB. They can be connected into the LAN via ethernet cables.
Is there any way to emulate the cameras as a local media device so that navigator.mediaDevices.enumerateDevices recognises them? Can I change the code or use any APIs to the detect IP cameras? Any pointers would be greatly helpful.
I have tried the options:
1. Add device in Windows Settings. Did not work as it requires specific Windows Insider update.
2. IP Camera Adapter, ManyCam, iSpy did not work as they all support HTTP. My HD cameras only support RTMP protocol.
v4l2loopback is one way you could do this! This allows you to feed a virtual webcam on Linux with arbitrary media.
Then you could have a pipeline in GStreamer that looks like
gst-launch-1.0 rtmpsrc location=$RTMP_SRC ! decodebin ! v4l2sink device=/dev/video0
This pipeline fetches the media from your RTMP server, decodes it and then pushes it to your new virtual webcam. Your device name may be different, ls /dev/video*
will be helpful. Then when you open Chromium you can choose a new virtual webcam that is being fed via rtmpsrc
.
As a follow up question, do you need to publish via Chromium? It is very easy to publish with something like Pion WebRTC you can give it arbitrary media and it can push to the browser. It also has examples on how you can pull from a rtmpsrc
.
Another solution could be OBS. It allows you to consume an RTMP Source
, and then you can output a Virtual Cam
. So OBS would serve a webcam that contains your produced content, which would just be one full screen video pulled from RTMP.