Use an IP-camera with webRTC

五迷三道 提交于 2019-11-28 06:01:27

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.

lulop

I have created a simple example transforming a RTSP or HTTP video feed into a WebRTC stream. This example is based on Kurento Media Server (KMS) and requires having it installed for the example to work.

Install KMS and enjoy ...

https://github.com/lulop-k/kurento-rtsp2webrtc

UPDATE 22-09-2015. Check this post for a technical explanation on why transcoding is just part of the solution to this problem.

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

If you have video4linux installed, the following command will create a virtual webcam from an rtsp stream:

  gst-launch rtspsrc location=rtsp://192.168.2.18/play.spd ! decodebin ! v4l2sink device=/dev/video1

You were on the right track, the "decodebin" was the missing link.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!