Use a IP-camera as a virtual camera

ffmpegip camerawebcam

I want to use an IP camera with webrtc. However webrtc seems to support only webcams. So I try to convert the IP camera's stream to a virtual webcam.

I found software like IP Camera Adapter, but they don't work well (2-3 frames per second and delay of 2 seconds) and they work only on Windows, I prefer use Linux (if possible).

I try ffmpeg/avconv:
-firstly, I created a virtual device with v4l2loopback (the command was: sudo modprobe v4l2loopback). The virtual device is detected and can be feed with a video (.avi) with a command like: ffmpeg -re -i testsrc.avi -f v4l2 /dev/video1

-the stream from the IP camera is available with: rtsp://IP/play2.sdp for a Dlink DCS-5222L camera. This stream can be captured by ffmpeg.

My problem is to make the link between these two steps (receive the rstp stream and write it to the virtual webcam). I tried ffmpeg -re -i rtsp://192.168.1.16/play2.sdp -f video4linux2 -input_format mjpeg -i /dev/video0 but there is an error with v4l2 (v4l2 not found).

Does anyones has an idea how to convert a stream from an IP-camera to a virtual camera?

Best Answer

FFMpeg can receive video from your IP Camera and forward it to the virtual camera device. For this you need to specify first all the parameters of your IP camera, as follows I guess:

-f video4linux2 -input_format mjpeg -i rtsp://192.168.1.16/play2.sdp

then all your output parameters, as you used in your example:

-f v4l2 /dev/video1

So try this command:

ffmpeg -f video4linux2 -input_format mjpeg -i rtsp://192.168.1.16/play2.sdp -f v4l2 /dev/video1
Related Question