14

I have small computer (something like Arduino or Raspberry pi) with Linux, camera and gstreamer installed on it. I need to stream h264 video from this device to browser using WebRTC technology. Also, I use NodeJS as signaling server.

In simple words, I need to doing a WebRTC client from my device. What is the best way to do this? Can I use WebRTC Native API for this goal? How can I install it on my small device? Or, maybe, I just need to play with my gstreamer and install some webrtc plugins for it?

3
  • Would you consider an external gateway that will handle the WebRTC connection, srtp decryption/encryption, that can stream up your video feed to a browser? If so, Janus Gateway does exactly this and there is even a gstreamer example(it uses VP8 but modifying codecs should not be that hard). I can explain further in an answer if you want to go this direction. Aug 23, 2014 at 17:02
  • @BenjaminTrent, external gateway is not the best way, but if there are nothing else, ofcourse, I will consider it. Does the Janus is something like NodeJS. Can it substitute NodeJS? Can I install it on CentOS, for example, and use it as web server? Thanks.
    – Footniko
    Aug 23, 2014 at 17:37
  • Janus is its own signalling server so there is no need for NodeJS. The same machine could be the web page host as well. The CPU utilization on Janus is very little but there are a handful of packets that are needed and that is why it may have to be a different machine than you embedded linux machine. Aug 23, 2014 at 18:04

4 Answers 4

8

Since you will have to use a signalling server anyways, I would say you should use the Janus-Gateway. You mention CentOS for your signalling server, I am not 100% if it will run on CentOS specifically, but I have ran it successfully in Debian Jessie build with just a few dependency installations.

Janus handles the entire call set up with the gateway(signalling and everything). So, some port forwarding will probably have to be done so that the SDP exchange can occur(which you would have to worry about with any signalling server).

  • Install the gateway, there are a few dependencies but all were simple installations

  • Take a look at the janus_streaming plugin. It has a gstreamer example that will stream from a gstreamer pipeline. Also, the streamingtest demo page to see how the Javascript API works for that plugin

  • The plugin listens on those ports given in the configuration file and will accept traffic from any IP address. So, I expect you can run a gstreamer pipeline on a different machine on the same network and send it to the plugin.

NOTE: You will have to modify the SDP that the JavaScipt sends to the gateway so that it includes H264(probably get rid of all other codecs as well just to force negotiation). You can do this by accessing the sdp through the jsep object passed to the success case for the createOffer function in the janus JavaScript API(jsep.sdp).

6
  • Thank you, Benjamin for your explanation. I will consider it.
    – Footniko
    Aug 25, 2014 at 7:50
  • @Footniko If you need any additional info, please ask. Also, the support from the dev team for this project has been very very fast if you need it. Aug 25, 2014 at 13:08
  • "It does not handle control packets for synchronization but I am writing a bidirectional plugin" Is that still true?
    – megawac
    Nov 26, 2014 at 21:12
  • Which specifically, that the gstreamer streaming in Janus does not handle control packets or a bidirectional streaming plugin for Janus? Nov 26, 2014 at 21:24
  • Now i'm using janus-gateway with my webcam and i able to stream audio/video from it to janus and show it as webrtc stream on the web page. But when i'm trying to stream from another device to the same audio/video port, there are some glitches with janus. Is it possible to establish the multi streaming to the janus?
    – Footniko
    Nov 29, 2014 at 17:58
5

Another possibility for you is to use the Kurento Media Server (KMS), which has been written on top of GStreamer. I see two possibilities

  1. You install KMS in a Ubuntu 14.04 box and bridge with your device, so that the device generates the video stream and sends it to the KMS box. From that, you can transcode it to VP9 and distribute it as a WebRTC stream quite easily using kurento client APIs (which may be used from Node.js). The application making the transcoding will require an RtpEndpoint (receiving video form the device in RTP/H.264) connected to a WebRtcEndpoint (capable of sending the video stream through WebRTC). This option is quite simple to implement because it's the standard way of using KMS. However, you will need to generate the RTP/H.264 stream on the device and appropriate SDP for it (this can be done using standard GStreamer elements)
  2. You try to install KMS into your box directly. This might be more complex because it requires compiling KMS to the specific device, which may require some time investment. In addition, performing the transcoding in the device might be too expensive and you could starve its CPU.

Disclaimer: I'm member of the Kurento development team

2

You mentioned that you used a NodeJS signaling server. Recently Ericsson released an open source WebRTC gstreamer element: http://www.openwebrtc.io/, and along with their release they also published a WebRTC demo using node.js: http://demo.openwebrtc.io:38080/; the code here: https://github.com/EricssonResearch/openwebrtc-examples/tree/master/server.

4
  • 1
    Is it possible to stream h.264 video from my device (using gstreamer) diretly to openwebrtc and then display it on web browser?
    – Footniko
    Oct 10, 2014 at 17:53
  • 1
    I haven't tested openwebrtc actually, I just know about it. Nonetheless, I've been able to display a gstreamer generated H.264 video in a WebRTC browser using the Janus Gateway, as recommended by Benjamin Trent. Check out my conversation with Lorenzo (Janus' author): groups.google.com/forum/#!topic/meetecho-janus/XjjboCTY0Xc
    – jcarballo
    Oct 21, 2014 at 1:20
  • Ericsson is still experimental and they state on their website it's not ready for production. Just FYI
    – Michael P
    Oct 16, 2015 at 0:05
  • Looks like the project is no longer maintainable.
    – Footniko
    Feb 16, 2019 at 16:56
1

For WebRTC for Raspberry Pi 2 you may want to consider UV4L. It allows you to stream live Audio & Video from the Rpi to any browser on a PC (HTML5).

1
  • Doesn't work terribly well if you're using a PiZero. He's crippled the functionality (Why? Just do reduced framerates...) to Pi2 and above.
    – Svartalf
    Oct 25, 2016 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.