Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use an IP-camera with webRTC

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 use an IP camera with webRTC?

like image 533
Minz Avatar asked May 04 '14 21:05

Minz


People also ask

Does WebRTC support RTSP?

This is a streaming server that supports RTSP and WebRTC protocols. It should connect to the IP camera via RTSP and fetch the video stream. Then, the stream is broadcast via WebRTC. You can install Web Call Server to your own host or run a preconfigured instance at Amazon EC2.

Does browser support RTSP?

As a rule, browsers do not support RTSP, so the video stream is converted for a browser using an intermediate server.

Does VLC support WebRTC?

You can watch WebRTC stream from either Ant Media Management console or other platforms such as VLC player with same RTMP URL. To Play with WebRTC, go to http://<server-address>:5080/WebRTCAppEE/player.html and enter the stream key parameter and click "Start Playing" button.


2 Answers

Short answer is, no. RTSP is not mentioned in the IETF standard for WebRTC and no browser currently has plans to support it. Link to Chrome discussion.

Longer answer is that if you are truly sold out on this idea, you will have to build a webrtc gateway/breaker utilizing the native WebRTC API.

  1. Start a WebRTC session between you browser and your breaker
  2. Grab the IP Camera feed with your gateway/breaker
  3. Encrypt and push the rtp stream to your WebRTC session from your RTSP stream gathered by the breaker through the WebRTC API.

This is how others have done it and how it will have to be done.

UPDATE 7/30/2014:

I have experimented with the janus-gateway and I believe the streaming plugin does EXACTLY this as it can grab an rtp stream and push it to an webrtc peer. For RTSP, you could probably create RTSP client(possibly using a library like gstreamer), then push the RTP and RTCP from the connection to the WebRTC peer.

like image 136
Benjamin Trent Avatar answered Sep 21 '22 02:09

Benjamin Trent


Janus-gateway recently added a simple RTSP support (based on libcurl) to its streaming plugins since this commit

Then it is possible to configure the gateway to negotiate RTSP with the camera and relay the RTP thought WebRTC adding in the streaming plugins configuration <prefix>/etc/janus/janus.plugin.streaming.cfg

[camera]
type = rtsp
id = 99
description = Dlink DCS-5222L camera
audio = no
video = yes
url=rtsp://192.168.1.16/play2.sdp

Next you will be able to access to the WebRTC stream using the streaming demo page http://..../demos/streamingtest.html

like image 35
mpromonet Avatar answered Sep 19 '22 02:09

mpromonet