Node.js WebRTC Streamer Project to Record V4L2 capture devices, RTSP Sources and Screen Capture in Javascript


CircleCI CirusCI Snap Status GithubCI GithubCI GithubCI

Codacy Badge

Release Download Docker Pulls

Heroku Gitpod ready-to-code



WebRTC-streamer is an experiment to stream video capture devices and RTSP sources through WebRTC using simple mechanism.

It embeds a HTTP server that implements API and serves a simple HTML page that use them through AJAX.

The WebRTC signaling is implemented through HTTP requests:

  • /api/call : send offer and get answer

  • /api/hangup : close a call

  • /api/addIceCandidate : add a candidate

  • /api/getIceCandidate : get the list of candidates

The list of HTTP API is available using /api/help.

Nowdays there is builds on CircleCICirrusCI and GitHub CI :

  • for x86_64 on Ubuntu Bionic
  • for armv7 crosscompiled (this build is running on Raspberry Pi2 and NanoPi NEO)
  • for armv6+vfp crosscompiled (this build is running on Raspberry PiB and should run on a Raspberry Zero)
  • for arm64 crosscompiled
  • Windows x64 build with clang
  • MacOS

The webrtc stream name could be :

  • an alias defined using -n argument then the corresponding -u argument will be used to create the capturer
  • an “rtsp://” url that will be openned using an RTSP capturer based on live555
  • an “file://” url that will be openned using an MKV capturer based on live555
  • an “screen://” url that will be openned by webrtc::DesktopCapturer::CreateScreenCapturer
  • an “window://” url that will be openned by webrtc::DesktopCapturer::CreateWindowCapturer
  • an “v4l2://” url that will capture H264 frames and store it using webrtc::VideoFrameBuffer::Type::kNative type (obviously not supported on Windows)
  • a capture device name

Dependencies :

It is based on :


Install the Chromium depot tools (for WebRTC).

Download WebRTC

Build WebRTC Streamer

It is possible to specify cmake parameters WEBRTCROOT & WEBRTCDESKTOPCAPTURE :

  • WEBRTCROOT/srcshouldcontainssource(defaultis(pwd)/../webrtc)
  • WEBRTCDESKTOPCAPTURE enabling desktop capture if available (default is ON)


Arguments of ‘-H’ are forwarded to option listening_ports of civetweb, then it is possible to use the civetweb syntax like -H8000,9000 or -H8080r,8443s.

Using -o allow to store compressed frame from backend stream using webrtc::VideoFrameBuffer::Type::kNative. This Hack the stucture webrtc::VideoFrameBuffer storing data in a override of i420 buffer. This allow to forward H264 frames from V4L2 device or RTSP stream to WebRTC stream. It use less CPU and have less adaptation (resize, codec, bandwidth are disabled).



Live Demo

We can access to the WebRTC stream using webrtcstreamer.html for instance :

An example displaying grid of WebRTC Streams is available using option “layout=x” Screenshot

Live Demo

Using embedded STUN/TURN server behind a NAT:

It is possible start embeded ICE server and publish its url using:

The command curl -s is getting the public IP, it could also given as a static parameter.

In order to configure the NAT rules using the upnp feature of the router, it is possible to use upnpc like this:

Adapting with the HTTP port, STUN port, TURN port.

Embed in a HTML page:

Instead of using the internal HTTP server, it is easy to display a WebRTC stream in a HTML page served by another HTTP server. The URL of the webrtc-streamer to use should be given creating the WebRtcStreamer instance :

A short sample HTML page using webrtc-streamer running locally on port 8000 :

Using WebComponent

Using web-component could be a simple way to display some webrtc stream, a minimal page could be :

Live Demo

Using the webcomponent with a stream selector :


Live Demo

Using the webcomponent over google map :


Live Demo

Object detection using tensorflow.js


Live Demo

Connect to Janus Gateway Video Room

A simple way to publish WebRTC stream to a Janus Gateway Video Room is to use the JanusVideoRoom interface

A short sample to publish WebRTC streams to Janus Video Room could be :


Live Demo

This way the communication between Janus API and WebRTC Streamer API is implemented in Javascript running in browser.

The same logic could be implemented in NodeJS using the same JS API :

Connect to Jitsi

A simple way to publish WebRTC stream to a Jitsi Video Room is to use the XMPPVideoRoom interface

A short sample to publish WebRTC streams to a Jitsi Video Room could be :

Live Demo

Docker image

You can start the application using the docker image :

You can expose V4L2 devices from your host using :

The container entry point is the webrtc-streamer application, then you can :

  • get the help using :

  • run the container registering a RTSP url using :

  • run the container giving config.json file using :

Leave a Reply