mediamtx icon indicating copy to clipboard operation
mediamtx copied to clipboard

Support reading with WebRTC

Open aler9 opened this issue 2 years ago • 2 comments

Fixes #566

Usage

  1. download a nightly release or build from source:

    rtsp-simple-server_v0.20.2-9-g9399f6a_darwin_amd64.tar.gz rtsp-simple-server_v0.20.2-9-g9399f6a_linux_amd64.tar.gz rtsp-simple-server_v0.20.2-9-g9399f6a_linux_arm64v8.tar.gz rtsp-simple-server_v0.20.2-9-g9399f6a_linux_armv6.tar.gz rtsp-simple-server_v0.20.2-9-g9399f6a_linux_armv7.tar.gz rtsp-simple-server_v0.20.2-9-g9399f6a_windows_amd64.zip

  2. get or generate a TLS certificate:

    openssl genrsa -out server.key 2048
    openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
    
  3. start the server and publish something

  4. visit `https://server-host:8889/path-of-the-stream

Configuration

# Disable support for the WebRTC protocol.
webrtcDisable: no
# Address of the WebRTC listener.
webrtcAddress: :8889
# Path to the server key. This is mandatory since HTTPS is mandatory in order to use WebRTC.
# This can be generated with:
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
webrtcServerKey: server.key
# Path to the server certificate.
webrtcServerCert: server.crt
# Value of the Access-Control-Allow-Origin header provided in every HTTP response.
# This allows to play the WebRTC stream from an external website.
webrtcAllowOrigin: '*'
# List of IPs or CIDRs of proxies placed before the WebRTC server.
# If the server receives a request from one of these entries, IP in logs
# will be taken from the X-Forwarded-For header.
webrtcTrustedProxies: []
# List of STUN servers. These are used in WebRTC to get the public IP of both server and clients.
webrtcStunServers: [stun.l.google.com:19302]

Roadmap

  • [x] read H264 tracks
  • [ ] read Opus tracks
  • [ ] read PCMA tracks
  • [ ] read PCMU tracks
  • [ ] read VP8 tracks
  • [ ] read VP9 tracks
  • [ ] authentication
  • [ ] API
  • [ ] metrics
  • [ ] TURN servers
  • [ ] publish video/audio from a browser
  • [ ] find a way to generate and store a TLS certificate if the default one is missing

aler9 avatar Nov 11 '22 21:11 aler9

Hello, first I would like to thank you for the beautiful work you have done, it is simply incredible. I would like to know in webrtc is it possible to add support to H265 in WS

brunobaraobr avatar Dec 13 '22 15:12 brunobaraobr

@brunobaraobr streaming H265 to the browser will be possible through Low-Latency HLS, please follow #469

Unfortunately WebRTC doesn't support H265 except when it's used inside macOS Safari, therefore at the moment it wouldn't be much useful to implement it.

aler9 avatar Dec 13 '22 15:12 aler9

Codecov Report

Merging #1242 (814ff45) into main (478607a) will decrease coverage by 4.12%. The diff coverage is 17.25%.

@@            Coverage Diff             @@
##             main    #1242      +/-   ##
==========================================
- Coverage   65.10%   60.98%   -4.13%     
==========================================
  Files         110      113       +3     
  Lines       11033    11805     +772     
==========================================
+ Hits         7183     7199      +16     
- Misses       3279     4033     +754     
- Partials      571      573       +2     
Impacted Files Coverage Δ
internal/conf/authmethod.go 0.00% <ø> (ø)
internal/conf/credential.go 0.00% <ø> (ø)
internal/conf/encryption.go 0.00% <ø> (ø)
internal/conf/hlsvariant.go 0.00% <ø> (ø)
internal/conf/ipsorcidrs.go 0.00% <ø> (ø)
internal/conf/logdestination.go 0.00% <ø> (ø)
internal/conf/loglevel.go 18.75% <ø> (ø)
internal/conf/protocol.go 30.00% <ø> (ø)
internal/conf/sourceprotocol.go 0.00% <ø> (ø)
internal/conf/stringduration.go 50.00% <ø> (ø)
... and 24 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Dec 15 '22 20:12 codecov-commenter