Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
January 7, 2023 15:32
July 8, 2023 20:15
October 29, 2023 12:41
April 19, 2022 00:01
November 16, 2019 16:52
April 29, 2023 17:37
October 29, 2023 22:22
December 20, 2019 23:19
November 16, 2023 23:49
September 11, 2022 18:40
July 29, 2023 20:54
November 19, 2023 19:08
October 8, 2023 19:29
February 12, 2022 22:38
March 20, 2022 16:40
February 22, 2021 15:58
October 29, 2023 22:29
October 28, 2023 18:04
October 28, 2023 22:14
March 13, 2021 16:45
January 22, 2023 19:02
November 1, 2023 12:51
October 28, 2018 12:15
March 1, 2022 19:12


A picture of a Nano PI NEO Air

CircleCI CirusCI Snap Status

GithubCI GithubCI GithubCI

Release Download Docker Pulls

Demo Gitpod ready-to-code

Experimentation to stream WebRTC media sources like capture devices, screen capture, mkv files and RMTP/RTSP sources using simple signaling mechanism (see api).



./webrtc-streamer [-H http port] [-S[embeded stun address]] -[v[v]]  [urls...]
./webrtc-streamer [-H http port] [-s[external stun address]] -[v[v]] [urls...]
./webrtc-streamer -V
	-v[v[v]]           : verbosity
	-V                 : print version
	-C config.json                     : load urls from JSON config file 
	-n name -u videourl -U audiourl    : register a name for a video url and an audio url
	[url]                              : url to register in the source list

	-H [hostname:]port : HTTP server binding (default
	-w webroot         : path to get files
	-c sslkeycert      : path to private key and certificate for HTTPS
	-N nbthreads       : number of threads for HTTP server
	-A passwd          : password file for HTTP server access
	-D authDomain      : authentication domain for HTTP server access (

	-S[stun_address]                   : start embeded STUN server bind to address (default
	-s[stun_address]                   : use an external STUN server ( , -:means no STUN)
	-T[username:password@]turn_address : start embeded TURN server (default:disabled)
	-t[username:password@]turn_address : use an external TURN relay server (default:disabled)
	-R [Udp port range min:max]        : Set the webrtc udp port range (default 0:65535)
	-W webrtc_trials_fields            : Set the webrtc trials fields (default:WebRTC-FrameDropper/Disabled/)		
	-a[audio layer]                    : spefify audio capture layer to use (default:0)		
	-q[filter]                         : spefify publish filter (default:.*)
	-o                                 : use null codec (keep frame encoded)

Arguments of '-H' are forwarded to option listening_ports of civetweb, allowing use of the civetweb syntax like -H8000,9000 or -H8080r,8443s.

Using -o allows storing compressed frame data from the backend stream using webrtc::VideoFrameBuffer::Type::kNative. This hacks the stucture webrtc::VideoFrameBuffer storing data in a override of the i420 buffer. This allows forwarding H264 frames from V4L2 device or RTSP stream to WebRTC stream. It uses less CPU, but has less features (resize, codec, and bandwidth are disabled).

Options for the WebRTC stream name:

  • an alias defined using -n argument then the corresponding -u argument will be used to create the capturer
  • an "rtsp://" url that will be opened using an RTSP capturer based on live555
  • an "file://" url that will be opened using an MKV capturer based on live555
  • an "rmtp://" url that will be opened using an RMTP capturer based on librmtp
  • an "screen://" url that will be opened by webrtc::DesktopCapturer::CreateScreenCapturer
  • an "window://" url that will be opened by webrtc::DesktopCapturer::CreateWindowCapturer
  • an "v4l2://" url that will capture H264 frames and store it using webrtc::VideoFrameBuffer::Type::kNative type (not supported on Windows)
  • an "videocap://" url video capture device name
  • an "audiocap://" url audio capture device name


./webrtc-streamer -C config.json


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=<lines>x<columns> Screenshot

Live Demo

Using docker image

You can start the application using the docker image:

docker run -p 8000:8000 -it mpromonet/webrtc-streamer

You can expose V4L2 devices from your host using:

docker run --device=/dev/video0 -p 8000:8000 -it mpromonet/webrtc-streamer

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

  • view all commands

    docker run -p 8000:8000 -it mpromonet/webrtc-streamer --help
  • run the container registering a RTSP url:

    docker run -p 8000:8000 -it mpromonet/webrtc-streamer -n raspicam -u rtsp://pi2.local:8554/unicast
  • run the container giving config.json file:

    docker run -p 8000:8000 -v $PWD/config.json:/app/config.json mpromonet/webrtc-streamer

Using embedded STUN/TURN server behind a NAT

It is possible to start an embeded STUN and TURN server and publish its URL:

./webrtc-streamer -S0.0.0.0:3478 -s$(curl -s
./webrtc-streamer -s- -T0.0.0.0:3478 -tturn:turn@$(curl -s
./webrtc-streamer -S0.0.0.0:3478 -s$(curl -s -T0.0.0.0:3479 -tturn:turn@$(curl -s

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:

upnpc -r 8000 tcp 3478 tcp 3478 udp

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

HTML Embedding

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:

var webRtcServer = new WebRtcStreamer(<video tag>, <webrtc-streamer url>);

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

<script src="libs/adapter.min.js" ></script>
<script src="webrtcstreamer.js" ></script>
	var webRtcServer      = null;
	window.onload         = function() { 
		webRtcServer      = new WebRtcStreamer("video",location.protocol+"//"+location.hostname+":8000");
	window.onbeforeunload = function() { webRtcServer.disconnect(); }
	<video id="video" />

Using WebComponents

WebRTC-streamer provides its own Web Components as an alternative way to display a WebRTC stream in an HTML page. For example:

	<script type="module" src="webrtc-streamer-element.js"></script>
	<webrtc-streamer url="rtsp://"></webrtc-streamer>

Live Demo

Using the webcomponent with a stream selector:


Live Demo

Using the webcomponent over google map:


Live Demo

Using WHEP

It allow to stream using draft standard WHEP

WebRTC player can display WebRTC stream from webrtc-streamer.

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

var janus = new JanusVideoRoom(<janus url>, <webrtc-streamer url>)

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

<script src="janusvideoroom.js" ></script>
	var janus = new JanusVideoRoom("", null);
	janus.join(1234, "rtsp://pi2.local:8554/unicast","pi2");
	janus.join(1234, "rtsp://","media");	    


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:

global.request = require("then-request");
var JanusVideoRoom = require("./html/janusvideoroom.js");
var janus = new JanusVideoRoom(
janus.join(1234, "videocap://0", "video");

Connect to Jitsi

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

var xmpp = new XMPPVideoRoom(<xmpp server url>, <webrtc-streamer url>)

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

<script src="libs/strophe.min.js" ></script>
<script src="libs/strophe.muc.min.js" ></script>
<script src="libs/strophe.disco.min.js" ></script>
<script src="libs/strophe.jingle.sdp.js"></script>
<script src="libs/jquery-3.5.1.min.js"></script>
<script src="xmppvideoroom.js" ></script>
	var xmpp = new XMPPVideoRoom("", null);
	xmpp.join("testroom", "rtsp://","Bunny");	    

Live Demo



This package depends on the following packages:

The following steps are required to build the project, and will install the dependencies above:

  1. Install the Chromium depot tools

    pushd ..
    git clone
    export PATH=$PATH:`realpath depot_tools`
  2. Download WebRTC

    mkdir ../webrtc
    pushd ../webrtc
    fetch --no-history webrtc 
  3. Build WebRTC Streamer

    cmake . && make

It is possible to specify cmake parameters WEBRTCROOT & WEBRTCDESKTOPCAPTURE:

  • $WEBRTCROOT/src should contains source (default is $(pwd)/../webrtc)
  • WEBRTCDESKTOPCAPTURE enabling desktop capture if available (default is ON)


There is pipelines on CircleCI, CirrusCI, or GitHub CI, for the following architectures:

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