# webrtc-streamer **Repository Path**: pan-fanxing/webrtc-streamer ## Basic Information - **Project Name**: webrtc-streamer - **Description**: No description available - **Primary Language**: Unknown - **License**: Unlicense - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-30 - **Last Updated**: 2026-08-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WebRTC-Streamer A picture of a Nano PI NEO Air [![CircleCI](https://img.shields.io/circleci/build/github/mpromonet/webrtc-streamer?label=circleci&logo=circleci)](https://circleci.com/gh/mpromonet/webrtc-streamer) [![Snap Status](https://snapcraft.io//webrtc-streamer/badge.svg)](https://snapcraft.io/webrtc-streamer) [![GithubCI](https://img.shields.io/github/actions/workflow/status/mpromonet/webrtc-streamer/cpp-linux.yml?label=C%2FC%2B%2B%20ci%20linux&logo=github)](https://github.com/mpromonet/webrtc-streamer/actions/workflows/cpp-linux.yml) [![GithubCI](https://img.shields.io/github/actions/workflow/status/mpromonet/webrtc-streamer/cpp-windows.yml?label=C%2FC%2B%2B%20ci%20windows&logo=github)](https://github.com/mpromonet/webrtc-streamer/actions/workflows/cpp-windows.yml) [![GithubCI](https://img.shields.io/github/actions/workflow/status/mpromonet/webrtc-streamer/cpp-macos.yml?label=C%2FC%2B%2B%20ci%20macos&logo=github)](https://github.com/mpromonet/webrtc-streamer/actions/workflows/cpp-macos.yml) [![Release](https://img.shields.io/github/release/mpromonet/webrtc-streamer.svg)](https://github.com/mpromonet/webrtc-streamer/releases/latest) [![Download](https://img.shields.io/github/downloads/mpromonet/webrtc-streamer/total.svg)](https://github.com/mpromonet/webrtc-streamer/releases/latest) [![Docker Pulls](https://img.shields.io/docker/pulls/mpromonet/webrtc-streamer.svg)](https://hub.docker.com/r/mpromonet/webrtc-streamer/) [![Demo](https://img.shields.io/badge/azure-livedemo-green)](https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/mpromonet/webrtc-streamer) Experimentation to stream WebRTC media sources like capture devices, screen capture, mkv files and RMTP/RTSP sources using simple signaling mechanism (see [api](docs/api.md)). It is also compatible with [WHEP](https://datatracker.ietf.org/doc/html/draft-ietf-wish-whep-01) interface. *** Notice *** Live demo are stopped till I migrate to a european web hosting. ## Artefacts * packages are available from https://github.com/mpromonet/webrtc-streamer/releases/latest * container image are available from https://hub.docker.com/r/mpromonet/webrtc-streamer ## Usage ```roff Usage: ./webrtc-streamer [OPTION...] [urls...] General options: -h, --help Print help -V, --version Print version -v, --verbose Verbosity level (use multiple times for more verbosity) -C, --config arg Load urls from JSON config file -n, --name arg Register a stream with name -u, --video arg Video URL for the named stream -U, --audio arg Audio URL for the named stream HTTP options: -H, --http arg HTTP server binding (default 0.0.0.0:8000) -w, --webroot arg Path to get static files -c, --cert arg Path to private key and certificate for HTTPS -N, --threads arg Number of threads for HTTP server -A, --passwd arg Password file for HTTP server access -D, --domain arg Authentication domain for HTTP server access (default:mydomain.com) -X, --disable-xframe Disable X-Frame-Options header -B, --base-path arg Base path for HTTP server WebRTC options: -m, --maxpc arg Maximum number of peer connections -I, --ice-transport arg Set ice transport type -T, --turn-server [=arg(=turn:turn@0.0.0.0:3478)] Start embedded TURN server -t, --turn arg Use an external TURN relay server -S, --stun-server [=arg(=0.0.0.0:3478)] Start embedded STUN server bind to address -s, --stun [=arg(=0.0.0.0:3478)] Use an external STUN server -R, --udp-range arg Set the webrtc udp port range -e, --extra-host arg Add extra ICE candidate address (for Docker/NAT) -W, --trials arg Set the webrtc trials fields -a, --audio-layer [=arg(=)] Specify audio capture layer to use (omit value for dummy audio) -q, --publish-filter arg Specify publish filter -o, --null-codec Use null codec (keep frame encoded) -b, --plan-b Use sdp plan-B (default use unifiedPlan) ``` Arguments of '-H' are forwarded to option [`listening_ports`](https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#listening_ports-8080) 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](https://en.wikipedia.org/wiki/Advanced_Video_Coding) 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 ```sh ./webrtc-streamer -C config.json ``` [![Screenshot](images/snapshot.png)](https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/) [Live Demo](https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/) We can access to the WebRTC stream using [webrtcstreamer.html](https://github.com/mpromonet/webrtc-streamer-html/blob/master/webrtcstreamer.html). For instance: - [webrtcstreamer.html?rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov](https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/webrtcstreamer.html?rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov) - [webrtcstreamer.html?Bunny](https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/webrtcstreamer.html?Bunny) An example displaying grid of WebRTC Streams is available using option `layout=x` [![Screenshot](images/layout2x4.png)](https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/?layout=2x4) [Live Demo](https://webrtcstreamer.agreeabletree-365b9a90.canadacentral.azurecontainerapps.io/?layout=2x4) ## Using docker image You can start the application using the docker image: ```sh docker run -p 8000:8000 -it mpromonet/webrtc-streamer ``` You can expose V4L2 devices from your host using: ```sh 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 ```sh docker run -p 8000:8000 -it mpromonet/webrtc-streamer --help ``` - run the container registering a RTSP url: ```sh docker run --name webrtc -d -p 8000:8000 -it mpromonet/webrtc-streamer -n raspicam -u rtsp://pi2.local:8554/unicast ``` - run the container giving config.json file: ```sh docker run --name webrtc -d -p 8000:8000 -v $PWD/config.json:/usr/local/share/webrtc-streamer/config.json mpromonet/webrtc-streamer ``` - run the container using network host: ```sh docker run --name webrtc -d --net host mpromonet/webrtc-streamer ``` - run the container adding extrahost ```sh docker run --name webrtc -d -p 8000:8000 --add-host host.docker.internal:host-gateway mpromonet/webrtc-streamer -e host.docker.internal ``` ## Using embedded STUN/TURN server behind a NAT It is possible to start an embeded [STUN](https://en.wikipedia.org/wiki/STUN) and [TURN](https://en.wikipedia.org/wiki/Traversal_Using_Relays_around_NAT) server and publish its URL: ```sh ./webrtc-streamer --stun-server=0.0.0.0:3478 --stun=$(curl -s ifconfig.me):3478 ./webrtc-streamer --stun=- --turn-server=0.0.0.0:3478 -tturn:turn@$(curl -s ifconfig.me):3478 ./webrtc-streamer --stun-server=0.0.0.0:3478 --stun=$(curl -s ifconfig.me):3478 --turn-server=0.0.0.0:3479 --turn=turn: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](https://manpages.debian.org/unstable/miniupnpc/upnpc.1.en.html) like this: ```sh 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](http://htmlpreview.github.io/?https://github.com/mpromonet/webrtc-streamer-html/blob/master/jsdoc/WebRtcStreamer.html) instance: ```js var webRtcServer = new WebRtcStreamer(