0.8.7-16-ge7664df • Published 9 months ago

webrtc-streamer v0.8.7-16-ge7664df

Weekly downloads
822
License
Unlicense
Repository
github
Last release
9 months ago

WebRTC-Streamer

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). It is also compatible with WHEP interface.

Artefacts

Usage

./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 0.0.0.0:8000)
	-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 (default:mydomain.com)

	-S[stun_address]                   : start embeded STUN server bind to address (default 0.0.0.0:3478)
	-s[stun_address]                   : use an external STUN server (default:stun.l.google.com:19302 , -: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

Examples

./webrtc-streamer -C config.json

Screenshot

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 ifconfig.me):3478
./webrtc-streamer -s- -T0.0.0.0:3478 -tturn:turn@$(curl -s ifconfig.me):3478
./webrtc-streamer -S0.0.0.0:3478 -s$(curl -s ifconfig.me):3478 -T0.0.0.0:3479 -tturn:turn@$(curl -s ifconfig.me):3479

The command curl -s ifconfig.me 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:

<html>
<head>
<script src="libs/adapter.min.js" ></script>
<script src="webrtcstreamer.js" ></script>
<script>        
	var webRtcServer      = null;
	window.onload         = function() { 
		webRtcServer      = new WebRtcStreamer("video",location.protocol+"//"+location.hostname+":8000");
		webRtcServer.connect("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");
	}
	window.onbeforeunload = function() { webRtcServer.disconnect(); }
</script>
</head>
<body> 
	<video id="video" />
</body>
</html>

Using WebComponents

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

<html>
<head>
	<script type="module" src="webrtc-streamer-element.js"></script>
</head>
<body>
	<webrtc-streamer url="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"></webrtc-streamer>
</body>
</html>

Live Demo

Using the webcomponent with a stream selector:

Screenshot

Live Demo

Using the webcomponent over google map:

Screenshot

Live Demo

Using WHEP

It allow to stream using draft standard WHEP

WebRTC player can display WebRTC stream from webrtc-streamer.

A minimal example:

<html>
<head>
    <script src="https://unpkg.com/@eyevinn/whep-video-component@latest/dist/whep-video.component.js"></script>
</head>
<body>
    <whep-video id="video" muted autoplay></whep-video>
    <script>
        video.setAttribute('src', `${location.origin}/api/whep?url=Asahi&options=rtptransport%3dtcp%26timeout%3d60`);
    </script>
</body>
</html>

Live Demo

Object detection using tensorflow.js

Screenshot

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:

<html>
<head>
<script src="janusvideoroom.js" ></script>
<script>        
	var janus = new JanusVideoRoom("https://janus.conf.meetecho.com/janus", null);
	janus.join(1234, "rtsp://pi2.local:8554/unicast","pi2");
	janus.join(1234, "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov","media");	    
</script>
</head>
</html>

Screenshot

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(
  "http://192.168.0.15:8088/janus",
  "http://192.168.0.15:8000",
);
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:

<html>
<head>
<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>
<script>        
	var xmpp = new XMPPVideoRoom("meet.jit.si", null);
	xmpp.join("testroom", "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov","Bunny");	    
</script>
</head>
</html>

Live Demo

Dependencies

This package depends on the following packages:

Build

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

  1. Install the Chromium depot tools

    pushd ..
    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    export PATH=$PATH:`realpath depot_tools`
    popd
  2. Download WebRTC

    mkdir ../webrtc
    pushd ../webrtc
    fetch --no-history webrtc 
    popd
  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)

Pipelines

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
0.8.7-6-g61e3ffb

9 months ago

0.8.7-15-gdadf698

9 months ago

0.8.7-10-ga841dc4

9 months ago

0.8.7-5-ga78053f

9 months ago

0.8.7-8-g7074433

9 months ago

0.8.7-13-g3429538

9 months ago

0.8.7-12-g0427c3e

9 months ago

0.8.7-16-ge7664df

9 months ago

0.8.7-9-gd4f4839

9 months ago

0.8.7-7-g189dd4b

9 months ago

0.8.7-14-gdbaa740

9 months ago

0.8.7-11-g272e023

9 months ago

0.8.7

10 months ago

0.8.6-26-g2822c7c

10 months ago

0.8.6-19-g8cf69ea

10 months ago

0.8.7-2-gc08e46c

10 months ago

0.8.6-13-gfa55094

10 months ago

0.8.6-24-gca568b3

10 months ago

0.8.6-25-g79b1f9c

10 months ago

0.8.6-18-g2ed67dc

10 months ago

0.8.6-28-g76daaa7

10 months ago

0.8.6-21-g8aafb96

10 months ago

0.8.6-19-g3d83f33

10 months ago

0.8.6-9-ge4c462e

10 months ago

0.8.6-8-gd97b7ad

10 months ago

0.8.6-14-gf2cfc33

10 months ago

0.8.6-16-gd46f200

10 months ago

0.8.6-27-g1a18d74

10 months ago

0.8.6-20-g6ae3c27

10 months ago

0.8.7-1-g2e48413

10 months ago

0.8.7-4-gaad9f99

9 months ago

0.8.6-12-g36d6d25

10 months ago

0.8.6-11-g4c2b984

10 months ago

0.8.6-29-g6dc08a6

10 months ago

0.8.6-16-g7cedfdd

10 months ago

0.8.6-31-g557826e

10 months ago

0.8.6-23-gb8b14b5

10 months ago

0.8.6-18-g5e38b71

10 months ago

0.8.6-15-g032db77

10 months ago

0.8.6-14-g7c97db8

10 months ago

0.8.6-17-g11f1a19

10 months ago

0.8.6-10-gd4ca20e

10 months ago

0.8.6-22-g57627e4

10 months ago

0.8.6-20-g46b4e0d

10 months ago

0.8.6-15-g3b2c0e1

10 months ago

0.8.7-3-ge6cf0a8

10 months ago

0.8.6-32-g7f72c58

10 months ago

0.8.6-14-g234b040

10 months ago

0.8.6-30-g54cf1c4

10 months ago

0.8.6-23-g3680015

10 months ago

0.8.6-22-g9d95d6e

10 months ago

0.8.6-18-g6d5280c

10 months ago

0.8.6-21-g7986ac1

10 months ago

0.8.6-17-ge8ac872

10 months ago

0.8.6

1 year ago

0.8.6-5-g946007b

11 months ago

0.8.6-4-g7e58bab

12 months ago

0.8.6-7-g4cfa382

11 months ago

0.8.6-3-gd22e80e

12 months ago

0.8.6-6-g3c472ac

11 months ago

0.8.5

1 year ago

0.8.4-2-g68e8d8e

2 years ago

0.8.3-7-g670560e

2 years ago

0.8.3-8-gec96bf4

2 years ago

0.8.4-4-gac42c0d

2 years ago

0.8.3-9-ga650d1c

2 years ago

0.8.3-6-g86abf05

2 years ago

0.8.4-7-gf803f6a

2 years ago

0.8.4-3-gf56d6ce

2 years ago

0.8.4-5-g3ba9317

2 years ago

0.8.4-8-gd0bef6c

2 years ago

0.8.4-1-g4516fe4

2 years ago

0.8.4-9-g093e8b2

2 years ago

0.8.3-5-gecc4dcb

2 years ago

0.8.4-6-gb038f03

2 years ago

0.8.1-4-g4ab32d6

2 years ago

0.8.1-6-g59de91b

2 years ago

0.8.0-8-ge6be770

2 years ago

0.8.3-2-g9338cde

2 years ago

0.8.2-4-g5a9bda1

2 years ago

0.8.1

2 years ago

0.8.1-7-g45a1a15

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.8.2-3-g707070a

2 years ago

0.8.1-8-g4933ed1

2 years ago

0.8.1-9-g1f61027

2 years ago

0.8.1-1-ga44a61c

2 years ago

0.8.3-3-g971bb1c

2 years ago

0.8.2-2-g4fe5c25

2 years ago

0.8.0-9-gb012719

2 years ago

0.8.3-4-g2d0afce

2 years ago

0.8.2-1-g48b8207

2 years ago

0.8.0-7-g2fc5709

2 years ago

0.8.2-4-g1a88adc

2 years ago

0.8.2-2-g4c989c5

2 years ago

0.8.2-1-g165377a

2 years ago

0.8.3-1-g81b641f

2 years ago

0.8.2-3-gf618b62

2 years ago

0.8.1-5-g5c1c29f

2 years ago

0.8.0-4-g1e5e457

2 years ago

0.8.0-1-gda56869

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.1-4-gcd46937

2 years ago

0.8.0

2 years ago

0.7.1-7-g975b4d5

2 years ago

0.7.2-9-g300af8b

2 years ago

0.8.0-3-g128ae2f

2 years ago

0.8.0-2-g757f99d

2 years ago

0.7.1-3-g2d7df9e

2 years ago

0.7.2-4-g40d0e30

2 years ago

0.7.2-6-gb2d0279

2 years ago

0.7.1-1-ge24bc28

2 years ago

0.7.2-5-g2b1b588

2 years ago

0.7.2-1-g7b9c690

2 years ago

0.8.0-5-gd82d9aa

2 years ago

0.7.1-8-g411a684

2 years ago

0.7.2-8-ge5cb4fe

2 years ago

0.8.0-6-g3716612

2 years ago

0.7.1-6-gea1f40b

2 years ago

0.7.2-2-g954538d

2 years ago

0.7.1-9-gc360ad4

2 years ago

0.7.1-2-g38f2c8f

2 years ago

0.7.2-7-gf9439a3

2 years ago

0.7.0-5-g8ac4044

3 years ago

0.7.0-6-g5400694

3 years ago

0.7.0-7-g3319c32

3 years ago

0.7.0-9-g376131d

3 years ago

0.7.0-4-gf460ae7

3 years ago

0.7.0

3 years ago

0.7.0-2-g5ddabe7

3 years ago

0.7.0-1-g79a4e06

3 years ago

0.7.0-3-gafc3f41

3 years ago

0.6.5-8-g05f8df2

3 years ago

0.6.5-9-g0031565

3 years ago

0.6.5-6-gbfab6ae

4 years ago

0.6.5-5-g12d8204

4 years ago

0.6.5-3-gb6e889a

4 years ago

0.6.5

4 years ago

0.6.5-1-gfc3a3d1

4 years ago

0.6.4-9-g12e50c3

4 years ago

0.6.4-7-gbce6923

4 years ago

0.6.4-6-gf51c198

4 years ago

0.6.4-5-g55ab130

4 years ago

0.6.4-4-g7d9d930

4 years ago

0.6.4-1-g1b228d5

4 years ago

0.6.4-3-g5d5b3a4

4 years ago

0.6.4-2-g0a7eb3b

4 years ago

0.6.4

4 years ago

0.6.3-5-g623bd1a

4 years ago

0.6.3-1-g229f768

4 years ago

0.6.3-9-g79815cd

4 years ago

0.6.3-8-g54371d9

4 years ago

0.6.3-6-g440310e

4 years ago

0.6.3-4-g258c2ac

4 years ago

0.6.3-3-g4c3864f

4 years ago

0.6.3-7-g6e5d46a

4 years ago

0.6.3-2-g632e1af

4 years ago

0.6.3

4 years ago

0.6.2-3-g70ed513

4 years ago

0.6.2-5-g8fe42b7

4 years ago

0.6.2-4-g250f894

4 years ago

0.6.2-6-ga9f0748

4 years ago

0.6.2-7-g7d383ad

4 years ago

0.6.1-3-g3c8de19

4 years ago

0.6.1-4-gde70d56

4 years ago

0.6.1-5-g97425e4

4 years ago

0.6.1-2-ge3b3fa1

4 years ago

0.6.2

4 years ago

0.6.1-1-gc83fe2f

4 years ago

0.6.0-1-gb15c7a3

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.2-7-g9395ae7

4 years ago

0.5.2-9-g0856591

4 years ago

0.5.2-8-gb892747

4 years ago

0.5.2-6-gfbeed31

4 years ago

0.5.2-5-g7ab98f5

4 years ago

0.5.2-3-g9d3c4f2

4 years ago

0.5.2-1-g15c8ac7

4 years ago

0.5.0-3-g3e051f7

4 years ago

0.5.0

4 years ago

0.5.2

4 years ago

0.3.5-9-g5765b35

4 years ago

0.3.5-8-gfd8dd7e

4 years ago

0.3.5-7-gc120124

4 years ago

0.3.5-6-g9170e74

4 years ago

0.3.5-5-g1067fea

4 years ago

0.3.5-4-gefd6368

4 years ago

0.3.5-2-g89879aa

4 years ago

0.3.5-3-g7883e79

4 years ago

0.3.5-1-g6cc8957

4 years ago

0.3.5

4 years ago

0.3.4-1-g104c258

4 years ago

0.3.4

4 years ago

0.3.3-7-g9c308c7

5 years ago

0.3.3-8-g71deb55

5 years ago

0.3.3-6-g64fb72c

5 years ago

0.3.3-5-g3ad6637

5 years ago

0.3.3-4-g2f472b5

5 years ago

0.3.3-3-g9458b5d

5 years ago

0.3.3-2-g0ffec4a

5 years ago

0.3.3

5 years ago

0.3.2-9-ge96ef20

5 years ago

0.3.2-8-g7543063

5 years ago

0.3.2-7-g674b5fa

5 years ago

0.3.2-6-g745a07f

5 years ago

0.3.2-5-gb51baf0

5 years ago

0.3.2-3-gd5ce002

5 years ago

0.3.2-4-g31e42d4

5 years ago

0.3.2-2-gd06fef5

5 years ago

0.3.2-1-g6e58529

5 years ago

0.3.2

5 years ago

0.3.1-2-g3c27ae4

5 years ago

0.3.1-1-g2171d33

5 years ago

0.3.1

5 years ago

0.3.0-2-g1f5fab2

5 years ago

0.3.0-1-ga020ecf

5 years ago

0.3.0

5 years ago

0.2.8-6-g6ecd8f6

5 years ago

0.2.8-4-gccf2c56

5 years ago

0.2.8

5 years ago

0.2.3-8

5 years ago

0.2.0-15

6 years ago

0.2.0-14

6 years ago

0.2.0-4

6 years ago

0.0.0

6 years ago

0.1.6-38

6 years ago