# webrtc-streamer **Repository Path**: wcg_5/webrtc-streamer ## Basic Information - **Project Name**: webrtc-streamer - **Description**: 基于WebRTC的二次开发,支持linux,rtsp, screen capture - **Primary Language**: Unknown - **License**: Unlicense - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 5 - **Created**: 2022-02-22 - **Last Updated**: 2025-07-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![CircleCI](https://circleci.com/gh/mpromonet/webrtc-streamer.svg?style=shield)](https://circleci.com/gh/mpromonet/webrtc-streamer) [![CirusCI](https://api.cirrus-ci.com/github/mpromonet/webrtc-streamer.svg)](https://cirrus-ci.com/github/mpromonet/webrtc-streamer) [![Snap Status](https://snapcraft.io//webrtc-streamer/badge.svg)](https://snapcraft.io/webrtc-streamer) [![GithubCI](https://github.com/mpromonet/webrtc-streamer/workflows/C/C++%20CI%20linux/badge.svg)](https://github.com/mpromonet/webrtc-streamer/actions/workflows/cpp-linux.yml) [![GithubCI](https://github.com/mpromonet/webrtc-streamer/workflows/C/C++%20CI%20windows/badge.svg)](https://github.com/mpromonet/webrtc-streamer/actions/workflows/cpp-windows.yml) [![GithubCI](https://github.com/mpromonet/webrtc-streamer/workflows/C/C++%20CI%20macos/badge.svg)](https://github.com/mpromonet/webrtc-streamer/actions/workflows/cpp-macos.yml) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/c209c81a15854964a08df5c300f56804)](https://www.codacy.com/app/michelpromonet_2643/webrtc-streamer?utm_source=github.com&utm_medium=referral&utm_content=mpromonet/webrtc-streamer&utm_campaign=badger) [![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/) [![Heroku](https://heroku-badge.herokuapp.com/?app=webrtc-streamer)](https://webrtc-streamer.herokuapp.com/) [![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) WebRTC-streamer =============== [![NanoPi](images/nanopi.jpg)](http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO_Air) 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 [CircleCI](https://circleci.com/gh/mpromonet/webrtc-streamer), [CirrusCI](https://cirrus-ci.com/github/mpromonet/webrtc-streamer) and [GitHub CI](https://github.com/mpromonet/webrtc-streamer/actions) : * 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 : * [WebRTC Native Code Package](http://www.webrtc.org) for WebRTC * [civetweb HTTP server](https://github.com/civetweb/civetweb) for HTTP server * [live555](http://www.live555.com/liveMedia) for RTSP/MKV source Build =============== Install the Chromium depot tools (for WebRTC). ------- pushd .. git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git export PATH=$PATH:`realpath depot_tools` popd Download WebRTC ------- mkdir ../webrtc pushd ../webrtc fetch --no-history webrtc popd 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) Usage =============== ./webrtc-streamer [-H http port] [-S[embeded stun address]] -[v[v]] [url1]...[urln] ./webrtc-streamer [-H http port] [-s[external stun address]] -[v[v]] [url1]...[urln] ./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 : use an external TURN relay server (default:disabled) -T[username:password@]turn_address : start embeded TURN 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](https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#listening_ports-8080) 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). Examples ----- ./webrtc-streamer rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov [![Screenshot](images/snapshot.png)](https://webrtc-streamer.herokuapp.com/) [Live Demo](https://webrtc-streamer.herokuapp.com/) We can access to the WebRTC stream using [webrtcstreamer.html](https://github.com/mpromonet/webrtc-streamer-html/blob/master/webrtcstreamer.html) for instance : * https://webrtc-streamer.herokuapp.com/webrtcstreamer.html?rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov * https://webrtc-streamer.herokuapp.com/webrtcstreamer.html?Bunny An example displaying grid of WebRTC Streams is available using option "layout=x" [![Screenshot](images/layout2x4.png)](https://webrtc-streamer.herokuapp.com/?layout=2x4) [Live Demo](https://webrtc-streamer.herokuapp.com/?layout=2x4) Using embedded STUN/TURN server behind a NAT: =============== It is possible start embeded ICE server and publish its url using: ./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](https://manpages.debian.org/unstable/miniupnpc/upnpc.1.en.html) like this: upnpc -r 8000 tcp 3478 tcp 3478 udp 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](http://htmlpreview.github.io/?https://github.com/mpromonet/webrtc-streamer-html/blob/master/jsdoc/WebRtcStreamer.html) instance : var webRtcServer = new WebRtcStreamer(