From b5b63d02fc1c55096cf5a035207d6e5694d1ab4d Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Tue, 2 Jun 2026 23:04:24 +0200 Subject: [PATCH] support reading and publishing with Media-over-QUIC (#5815) Media-over-QUIC is a streaming protocol built upon cutting edge protocols (QUIC, HTTP3) and browser APIs (WebTransport, WebCodecs). It's slightly faster than WebRTC, has an advanced data recovery mechanism (placed at the frame level and not at the packet level), it supports additional codecs (FLAC) and is less complicated to route. --- .dockerignore | 4 + .gitignore | 4 + README.md | 4 +- api/openapi.yaml | 174 +++ docs/1-kickoff/1-introduction.md | 4 +- docs/2-features/03-publish.md | 41 +- docs/2-features/04-read.md | 27 +- docs/2-features/06-authentication.md | 4 +- .../16-expose-the-server-in-a-subfolder.md | 14 +- docs/2-features/23-metrics.md | 8 +- docs/2-features/25-srt-specific-features.md | 2 +- .../2-features/26-webrtc-specific-features.md | 2 +- docs/2-features/27-rtsp-specific-features.md | 4 +- docs/2-features/28-rtmp-specific-features.md | 2 +- docs/3-publish/01-moq-clients.md | 36 + .../{01-srt-clients.md => 02-srt-clients.md} | 2 +- ...rvers.md => 04-srt-cameras-and-servers.md} | 0 ...webrtc-clients.md => 05-webrtc-clients.md} | 2 +- ...webrtc-servers.md => 06-webrtc-servers.md} | 2 +- ...{05-rtsp-clients.md => 07-rtsp-clients.md} | 2 +- ...vers.md => 08-rtsp-cameras-and-servers.md} | 0 ...{07-rtmp-clients.md => 09-rtmp-clients.md} | 2 +- ...vers.md => 10-rtmp-cameras-and-servers.md} | 0 ...rvers.md => 11-hls-cameras-and-servers.md} | 0 .../{10-mpeg-ts.md => 12-mpeg-ts.md} | 2 +- docs/3-publish/{11-rtp.md => 13-rtp.md} | 2 +- ...-cameras.md => 14-raspberry-pi-cameras.md} | 0 ...neric-webcams.md => 15-generic-webcams.md} | 0 ...{14-web-browsers.md => 16-web-browsers.md} | 22 +- docs/3-publish/{15-ffmpeg.md => 17-ffmpeg.md} | 12 +- .../{16-gstreamer.md => 18-gstreamer.md} | 10 +- .../{17-obs-studio.md => 19-obs-studio.md} | 8 +- ...8-python-opencv.md => 20-python-opencv.md} | 2 +- docs/3-publish/{19-golang.md => 21-golang.md} | 0 docs/3-publish/{20-unity.md => 22-unity.md} | 2 +- docs/4-read/01-moq.md | 18 + docs/4-read/{01-srt.md => 02-srt.md} | 2 +- docs/4-read/{02-webrtc.md => 03-webrtc.md} | 2 +- docs/4-read/{03-rtsp.md => 04-rtsp.md} | 2 +- docs/4-read/{04-rtmp.md => 05-rtmp.md} | 2 +- docs/4-read/{05-hls.md => 06-hls.md} | 2 +- ...{06-web-browsers.md => 07-web-browsers.md} | 20 +- docs/4-read/{07-ffmpeg.md => 08-ffmpeg.md} | 2 +- .../{08-gstreamer.md => 09-gstreamer.md} | 2 +- docs/4-read/{09-vlc.md => 10-vlc.md} | 2 +- .../{10-obs-studio.md => 11-obs-studio.md} | 2 +- ...1-python-opencv.md => 12-python-opencv.md} | 2 +- docs/4-read/{12-golang.md => 13-golang.md} | 0 docs/4-read/{13-unity.md => 14-unity.md} | 2 +- docs/6-misc/4-specifications.md | 37 +- docs/6-misc/5-related-projects.md | 2 + go.mod | 5 +- go.sum | 4 + internal/api/api.go | 12 +- internal/api/api_moq.go | 68 + internal/api/api_moq_test.go | 181 +++ internal/auth/request.go | 1 + internal/certloader/certloader.go | 134 +- internal/conf/conf.go | 17 + internal/core/api_test.go | 11 +- internal/core/core.go | 47 + internal/core/metrics_test.go | 10 + internal/core/path_manager.go | 10 +- internal/defs/api_moq.go | 44 + internal/defs/api_path.go | 2 + internal/defs/path_access_request.go | 2 +- internal/metrics/metrics.go | 50 +- internal/metrics/metrics_test.go | 75 + internal/playback/server.go | 5 +- internal/pprof/pprof.go | 5 +- internal/protocols/httpp/server.go | 21 +- internal/protocols/httpp3/server.go | 197 +++ internal/protocols/httpp3/server_test.go | 43 + internal/protocols/moq/catalog/catalog.go | 26 + .../protocols/moq/controlmessage/message.go | 65 + .../moq/controlmessage/message_test.go | 174 +++ .../protocols/moq/controlmessage/publish.go | 145 ++ .../moq/controlmessage/request_error.go | 87 ++ .../moq/controlmessage/request_ok.go | 63 + .../protocols/moq/controlmessage/setup.go | 31 + .../protocols/moq/controlmessage/subscribe.go | 128 ++ .../moq/controlmessage/subscribe_ok.go | 75 + internal/protocols/moq/from_stream.go | 318 +++++ internal/protocols/moq/from_stream_test.go | 111 ++ .../moq/parameter/authorization_token.go | 84 ++ internal/protocols/moq/parameter/parameter.go | 91 ++ .../protocols/moq/parameter/parameter_test.go | 60 + internal/protocols/moq/property/property.go | 105 ++ .../protocols/moq/property/property_test.go | 50 + internal/protocols/moq/property/timestamp.go | 33 + internal/protocols/moq/reorderer/reorderer.go | 88 ++ .../protocols/moq/reorderer/reorderer_test.go | 163 +++ internal/protocols/moq/subgroup/header.go | 70 + internal/protocols/moq/subgroup/object.go | 120 ++ internal/protocols/moq/subgroup/subgroup.go | 70 + .../protocols/moq/subgroup/subgroup_test.go | 92 ++ internal/protocols/moq/to_stream.go | 199 +++ internal/protocols/moq/to_stream_test.go | 69 + internal/protocols/moq/track.go | 18 + internal/protocols/moq/varint/varint.go | 245 ++++ internal/protocols/moq/varint/varint_test.go | 91 ++ internal/servers/hls/http_server.go | 2 - internal/servers/hls/index.html | 4 +- internal/servers/hls/server.go | 4 +- internal/servers/moq/http_server.go | 342 +++++ internal/servers/moq/inbound_track.go | 38 + internal/servers/moq/publish_index.html | 480 +++++++ internal/servers/moq/publisher.js | 822 +++++++++++ internal/servers/moq/read_index.html | 111 ++ internal/servers/moq/reader.js | 1263 +++++++++++++++++ internal/servers/moq/server.go | 304 ++++ internal/servers/moq/server_test.go | 179 +++ internal/servers/moq/session.go | 744 ++++++++++ internal/servers/rtmp/server.go | 4 +- internal/servers/rtsp/server.go | 4 +- internal/servers/srt/server.go | 4 +- mediamtx.yml | 84 +- 117 files changed, 8515 insertions(+), 188 deletions(-) create mode 100644 docs/3-publish/01-moq-clients.md rename docs/3-publish/{01-srt-clients.md => 02-srt-clients.md} (90%) rename docs/3-publish/{02-srt-cameras-and-servers.md => 04-srt-cameras-and-servers.md} (100%) rename docs/3-publish/{03-webrtc-clients.md => 05-webrtc-clients.md} (91%) rename docs/3-publish/{04-webrtc-servers.md => 06-webrtc-servers.md} (93%) rename docs/3-publish/{05-rtsp-clients.md => 07-rtsp-clients.md} (90%) rename docs/3-publish/{06-rtsp-cameras-and-servers.md => 08-rtsp-cameras-and-servers.md} (100%) rename docs/3-publish/{07-rtmp-clients.md => 09-rtmp-clients.md} (86%) rename docs/3-publish/{08-rtmp-cameras-and-servers.md => 10-rtmp-cameras-and-servers.md} (100%) rename docs/3-publish/{09-hls-cameras-and-servers.md => 11-hls-cameras-and-servers.md} (100%) rename docs/3-publish/{10-mpeg-ts.md => 12-mpeg-ts.md} (96%) rename docs/3-publish/{11-rtp.md => 13-rtp.md} (96%) rename docs/3-publish/{12-raspberry-pi-cameras.md => 14-raspberry-pi-cameras.md} (100%) rename docs/3-publish/{13-generic-webcams.md => 15-generic-webcams.md} (100%) rename docs/3-publish/{14-web-browsers.md => 16-web-browsers.md} (58%) rename docs/3-publish/{15-ffmpeg.md => 17-ffmpeg.md} (75%) rename docs/3-publish/{16-gstreamer.md => 18-gstreamer.md} (81%) rename docs/3-publish/{17-obs-studio.md => 19-obs-studio.md} (95%) rename docs/3-publish/{18-python-opencv.md => 20-python-opencv.md} (96%) rename docs/3-publish/{19-golang.md => 21-golang.md} (100%) rename docs/3-publish/{20-unity.md => 22-unity.md} (98%) create mode 100644 docs/4-read/01-moq.md rename docs/4-read/{01-srt.md => 02-srt.md} (89%) rename docs/4-read/{02-webrtc.md => 03-webrtc.md} (95%) rename docs/4-read/{03-rtsp.md => 04-rtsp.md} (88%) rename docs/4-read/{04-rtmp.md => 05-rtmp.md} (86%) rename docs/4-read/{05-hls.md => 06-hls.md} (96%) rename docs/4-read/{06-web-browsers.md => 07-web-browsers.md} (90%) rename docs/4-read/{07-ffmpeg.md => 08-ffmpeg.md} (84%) rename docs/4-read/{08-gstreamer.md => 09-gstreamer.md} (94%) rename docs/4-read/{09-vlc.md => 10-vlc.md} (90%) rename docs/4-read/{10-obs-studio.md => 11-obs-studio.md} (91%) rename docs/4-read/{11-python-opencv.md => 12-python-opencv.md} (89%) rename docs/4-read/{12-golang.md => 13-golang.md} (100%) rename docs/4-read/{13-unity.md => 14-unity.md} (98%) create mode 100644 internal/api/api_moq.go create mode 100644 internal/api/api_moq_test.go create mode 100644 internal/defs/api_moq.go create mode 100644 internal/protocols/httpp3/server.go create mode 100644 internal/protocols/httpp3/server_test.go create mode 100644 internal/protocols/moq/catalog/catalog.go create mode 100644 internal/protocols/moq/controlmessage/message.go create mode 100644 internal/protocols/moq/controlmessage/message_test.go create mode 100644 internal/protocols/moq/controlmessage/publish.go create mode 100644 internal/protocols/moq/controlmessage/request_error.go create mode 100644 internal/protocols/moq/controlmessage/request_ok.go create mode 100644 internal/protocols/moq/controlmessage/setup.go create mode 100644 internal/protocols/moq/controlmessage/subscribe.go create mode 100644 internal/protocols/moq/controlmessage/subscribe_ok.go create mode 100644 internal/protocols/moq/from_stream.go create mode 100644 internal/protocols/moq/from_stream_test.go create mode 100644 internal/protocols/moq/parameter/authorization_token.go create mode 100644 internal/protocols/moq/parameter/parameter.go create mode 100644 internal/protocols/moq/parameter/parameter_test.go create mode 100644 internal/protocols/moq/property/property.go create mode 100644 internal/protocols/moq/property/property_test.go create mode 100644 internal/protocols/moq/property/timestamp.go create mode 100644 internal/protocols/moq/reorderer/reorderer.go create mode 100644 internal/protocols/moq/reorderer/reorderer_test.go create mode 100644 internal/protocols/moq/subgroup/header.go create mode 100644 internal/protocols/moq/subgroup/object.go create mode 100644 internal/protocols/moq/subgroup/subgroup.go create mode 100644 internal/protocols/moq/subgroup/subgroup_test.go create mode 100644 internal/protocols/moq/to_stream.go create mode 100644 internal/protocols/moq/to_stream_test.go create mode 100644 internal/protocols/moq/track.go create mode 100644 internal/protocols/moq/varint/varint.go create mode 100644 internal/protocols/moq/varint/varint_test.go create mode 100644 internal/servers/moq/http_server.go create mode 100644 internal/servers/moq/inbound_track.go create mode 100644 internal/servers/moq/publish_index.html create mode 100644 internal/servers/moq/publisher.js create mode 100644 internal/servers/moq/read_index.html create mode 100644 internal/servers/moq/reader.js create mode 100644 internal/servers/moq/server.go create mode 100644 internal/servers/moq/server_test.go create mode 100644 internal/servers/moq/session.go diff --git a/.dockerignore b/.dockerignore index 5e31ad1f..3f876a0f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,3 +6,7 @@ /internal/core/VERSION /internal/servers/hls/hls.min.js /internal/staticsources/rpicamera/mtxrpicam_*/ +/auto.crt +/auto.key +/internal/core/auto.crt +/internal/core/auto.key diff --git a/.gitignore b/.gitignore index e2a09ccf..05859fd5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ /internal/core/VERSION /internal/servers/hls/hls.min.js /internal/staticsources/rpicamera/mtxrpicam_*/ +/auto.crt +/auto.key +/internal/core/auto.crt +/internal/core/auto.key diff --git a/README.md b/README.md index 6f3f79aa..3e1c9410 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ _MediaMTX_ is a ready-to-use and zero-dependency real-time media server and medi

Features

-- [Publish](https://mediamtx.org/docs/features/publish) live streams to the server with SRT, WebRTC, RTSP, RTMP, HLS, MPEG-TS, RTP, using FFmpeg, GStreamer, OBS Studio, Python , Golang, Unity, web browsers, Raspberry Pi Cameras and more. -- [Read](https://mediamtx.org/docs/features/read) live streams from the server with SRT, WebRTC, RTSP, RTMP, HLS, using FFmpeg, GStreamer, VLC, OBS Studio, Python , Golang, Unity, web browsers and more. +- [Publish](https://mediamtx.org/docs/features/publish) live streams to the server with Media-over-QUIC, SRT, WebRTC, RTSP, RTMP, HLS, MPEG-TS, RTP, using FFmpeg, GStreamer, OBS Studio, Python , Golang, Unity, web browsers, Raspberry Pi Cameras and more. +- [Read](https://mediamtx.org/docs/features/read) live streams from the server with Media-over-QUIC, SRT, WebRTC, RTSP, RTMP, HLS, using FFmpeg, GStreamer, VLC, OBS Studio, Python , Golang, Unity, web browsers and more. - Streams are automatically converted from a protocol to another - Serve several streams at once in separate paths - Reload the configuration without disconnecting existing clients (hot reloading) diff --git a/api/openapi.yaml b/api/openapi.yaml index 513cdd7f..029b3c75 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -155,6 +155,10 @@ components: type: string enum: [read, publish] + MoQSessionState: + type: string + enum: [idle, read, publish] + OK: type: object properties: @@ -594,6 +598,26 @@ components: srtAddress: type: string + # MoQ server + moq: + type: boolean + moqHTTPS2Address: + type: string + moqHTTPS3Address: + type: string + moqServerKey: + type: string + moqServerCert: + type: string + moqAllowOrigins: + type: array + items: + type: string + moqTrustedProxies: + type: array + items: + type: string + # Record (deprecated) record: type: boolean @@ -1856,6 +1880,39 @@ components: items: $ref: "#/components/schemas/WebRTCSession" + MoQSession: + type: object + properties: + id: + type: string + format: uuid + created: + type: string + remoteAddr: + type: string + state: + $ref: "#/components/schemas/MoQSessionState" + path: + type: string + query: + type: string + userAgent: + type: string + + MoQSessionList: + type: object + properties: + pageCount: + type: integer + format: int64 + itemCount: + type: integer + format: int64 + items: + type: array + items: + $ref: "#/components/schemas/MoQSession" + paths: /v3/info: get: @@ -3388,6 +3445,123 @@ paths: schema: $ref: "#/components/schemas/Error" + /v3/moqsessions/list: + get: + operationId: moqSessionsList + tags: [MoQ] + summary: returns all MoQ sessions. + description: "" + parameters: + - name: page + in: query + description: page number. + schema: + type: integer + default: 0 + - name: itemsPerPage + in: query + description: items per page. + schema: + type: integer + default: 100 + responses: + "200": + description: the request was successful. + content: + application/json: + schema: + $ref: "#/components/schemas/MoQSessionList" + "400": + description: invalid request. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "500": + description: server error. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /v3/moqsessions/get/{id}: + get: + operationId: moqSessionsGet + tags: [MoQ] + summary: returns a MoQ session. + description: "" + parameters: + - name: id + in: path + required: true + description: ID of the session. + schema: + type: string + responses: + "200": + description: the request was successful. + content: + application/json: + schema: + $ref: "#/components/schemas/MoQSession" + "400": + description: invalid request. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "404": + description: session not found. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "500": + description: server error. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /v3/moqsessions/kick/{id}: + post: + operationId: moqSessionsKick + tags: [MoQ] + summary: kicks out a MoQ session from the server. + description: "" + parameters: + - name: id + in: path + required: true + description: ID of the session. + schema: + type: string + responses: + "200": + description: the request was successful. + content: + application/json: + schema: + $ref: "#/components/schemas/OK" + "400": + description: invalid request. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "404": + description: session not found. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + "500": + description: server error. + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /v3/recordings/list: get: operationId: recordingsList diff --git a/docs/1-kickoff/1-introduction.md b/docs/1-kickoff/1-introduction.md index cd276db5..f31261f8 100644 --- a/docs/1-kickoff/1-introduction.md +++ b/docs/1-kickoff/1-introduction.md @@ -6,8 +6,8 @@ _MediaMTX_ is a ready-to-use and zero-dependency live media server and media pro Main features: -- [Publish](../2-features/03-publish.md) live streams to the server with SRT, WebRTC, RTSP, RTMP, HLS, MPEG-TS, RTP, using FFmpeg, GStreamer, OBS Studio, Python , Golang, Unity, Web browsers, Raspberry Pi Cameras and more. -- [Read](../2-features/04-read.md) live streams from the server with SRT, WebRTC, RTSP, RTMP, HLS, using FFmpeg, GStreamer, VLC, OBS Studio, Python , Golang, Unity, Web browsers and more. +- [Publish](../2-features/03-publish.md) live streams to the server with Media-over-QUIC, SRT, WebRTC, RTSP, RTMP, HLS, MPEG-TS, RTP, using FFmpeg, GStreamer, OBS Studio, Python , Golang, Unity, Web browsers, Raspberry Pi Cameras and more. +- [Read](../2-features/04-read.md) live streams from the server with Media-over-QUIC, SRT, WebRTC, RTSP, RTMP, HLS, using FFmpeg, GStreamer, VLC, OBS Studio, Python , Golang, Unity, Web browsers and more. - Streams are automatically converted from a protocol to another - Serve several streams at once in separate paths - Reload the configuration without disconnecting existing clients (hot reloading) diff --git a/docs/2-features/03-publish.md b/docs/2-features/03-publish.md index deedac41..4ff73f13 100644 --- a/docs/2-features/03-publish.md +++ b/docs/2-features/03-publish.md @@ -2,29 +2,30 @@ Live streams can be published to the server with the following protocols: -- [SRT clients](../3-publish/01-srt-clients.md) -- [SRT cameras and servers](../3-publish/02-srt-cameras-and-servers.md) -- [WebRTC clients](../3-publish/03-webrtc-clients.md) -- [WebRTC servers](../3-publish/04-webrtc-servers.md) -- [RTSP clients](../3-publish/05-rtsp-clients.md) -- [RTSP cameras and servers](../3-publish/06-rtsp-cameras-and-servers.md) -- [RTMP clients](../3-publish/07-rtmp-clients.md) -- [RTMP cameras and servers](../3-publish/08-rtmp-cameras-and-servers.md) -- [HLS cameras and servers](../3-publish/09-hls-cameras-and-servers.md) -- [MPEG-TS](../3-publish/10-mpeg-ts.md) -- [RTP](../3-publish/11-rtp.md) +- [Media-over-QUIC clients](../3-publish/01-moq-clients.md) +- [SRT clients](../3-publish/02-srt-clients.md) +- [SRT cameras and servers](../3-publish/04-srt-cameras-and-servers.md) +- [WebRTC clients](../3-publish/05-webrtc-clients.md) +- [WebRTC servers](../3-publish/06-webrtc-servers.md) +- [RTSP clients](../3-publish/07-rtsp-clients.md) +- [RTSP cameras and servers](../3-publish/08-rtsp-cameras-and-servers.md) +- [RTMP clients](../3-publish/09-rtmp-clients.md) +- [RTMP cameras and servers](../3-publish/10-rtmp-cameras-and-servers.md) +- [HLS cameras and servers](../3-publish/11-hls-cameras-and-servers.md) +- [MPEG-TS](../3-publish/12-mpeg-ts.md) +- [RTP](../3-publish/13-rtp.md) We provide instructions for publishing with the following devices: -- [Raspberry Pi Cameras](../3-publish/12-raspberry-pi-cameras.md) -- [Generic webcams](../3-publish/13-generic-webcams.md) +- [Raspberry Pi Cameras](../3-publish/14-raspberry-pi-cameras.md) +- [Generic webcams](../3-publish/15-generic-webcams.md) We provide instructions for publishing with the following software: -- [Web browsers](../3-publish/14-web-browsers.md) -- [FFmpeg](../3-publish/15-ffmpeg.md) -- [GStreamer](../3-publish/16-gstreamer.md) -- [OBS Studio](../3-publish/17-obs-studio.md) -- [Python and OpenCV](../3-publish/18-python-opencv.md) -- [Golang](../3-publish/19-golang.md) -- [Unity](../3-publish/20-unity.md) +- [Web browsers](../3-publish/16-web-browsers.md) +- [FFmpeg](../3-publish/17-ffmpeg.md) +- [GStreamer](../3-publish/18-gstreamer.md) +- [OBS Studio](../3-publish/19-obs-studio.md) +- [Python and OpenCV](../3-publish/20-python-opencv.md) +- [Golang](../3-publish/21-golang.md) +- [Unity](../3-publish/22-unity.md) diff --git a/docs/2-features/04-read.md b/docs/2-features/04-read.md index 2d799bf2..7f729289 100644 --- a/docs/2-features/04-read.md +++ b/docs/2-features/04-read.md @@ -2,19 +2,20 @@ Live streams can be read from the server with the following protocols: -- [SRT clients](../4-read/01-srt.md) -- [WebRTC clients](../4-read/02-webrtc.md) -- [RTSP clients](../4-read/03-rtsp.md) -- [RTMP clients](../4-read/04-rtmp.md) -- [HLS](../4-read/05-hls.md) +- [Media-over-QUIC clients](../4-read/01-moq.md) +- [SRT clients](../4-read/02-srt.md) +- [WebRTC clients](../4-read/03-webrtc.md) +- [RTSP clients](../4-read/04-rtsp.md) +- [RTMP clients](../4-read/05-rtmp.md) +- [HLS](../4-read/06-hls.md) We provide instructions for reading with the following software: -- [Web browsers](../4-read/06-web-browsers.md) -- [FFmpeg](../4-read/07-ffmpeg.md) -- [GStreamer](../4-read/08-gstreamer.md) -- [VLC](../4-read/09-vlc.md) -- [OBS Studio](../4-read/10-obs-studio.md) -- [Python and OpenCV](../4-read/11-python-opencv.md) -- [Golang](../4-read/12-golang.md) -- [Unity](../4-read/13-unity.md) +- [Web browsers](../4-read/07-web-browsers.md) +- [FFmpeg](../4-read/08-ffmpeg.md) +- [GStreamer](../4-read/09-gstreamer.md) +- [VLC](../4-read/10-vlc.md) +- [OBS Studio](../4-read/11-obs-studio.md) +- [Python and OpenCV](../4-read/12-python-opencv.md) +- [Golang](../4-read/13-golang.md) +- [Unity](../4-read/14-unity.md) diff --git a/docs/2-features/06-authentication.md b/docs/2-features/06-authentication.md index 05ff2bb3..dada730c 100644 --- a/docs/2-features/06-authentication.md +++ b/docs/2-features/06-authentication.md @@ -299,7 +299,7 @@ Username and password can be passed through the `Authorization: Basic` HTTP head Authorization: Basic base64(myuser:mypass) ``` -When using a web browser, a dialog is first shown to users, asking for credentials, and then the header is automatically inserted into every request. If you need to automatically fill credentials from a parent web page, read [Embed in a website](../4-read/06-web-browsers.md#embed-in-a-website). +When using a web browser, a dialog is first shown to users, asking for credentials, and then the header is automatically inserted into every request. If you need to automatically fill credentials from a parent web page, read [Embed in a website](../4-read/07-web-browsers.md#embed-in-a-website). If the `Authorization: Basic` header cannot be used (for instance, in software like OBS Studio, which only allows to provide a "Bearer Token"), credentials can be passed through the `Authorization: Bearer` header (i.e. the "Bearer Token" in OBS), where the value is the concatenation of username and password, separated by a colon: @@ -351,4 +351,4 @@ In OBS Studio, this is the "Bearer Token" field. If the `Authorization: Bearer` token cannot be directly provided (for instance, with web browsers that directly access _MediaMTX_ and show a credential dialog), you can pass the token as password, using an arbitrary user. -In web browsers, if you need to automatically fill credentials from a parent web page, read [Embed in a website](../4-read/06-web-browsers.md#embed-in-a-website). +In web browsers, if you need to automatically fill credentials from a parent web page, read [Embed in a website](../4-read/07-web-browsers.md#embed-in-a-website). diff --git a/docs/2-features/16-expose-the-server-in-a-subfolder.md b/docs/2-features/16-expose-the-server-in-a-subfolder.md index 06ceb8d1..b4221f53 100644 --- a/docs/2-features/16-expose-the-server-in-a-subfolder.md +++ b/docs/2-features/16-expose-the-server-in-a-subfolder.md @@ -1,12 +1,14 @@ # Expose the server in a subfolder -HTTP-based services (WebRTC, HLS, Control API, Playback Server, Metrics, pprof) can be exposed in a subfolder of an existing HTTP server or reverse proxy. The reverse proxy must be able to intercept HTTP requests addressed to _MediaMTX_ and corresponding responses, and perform the following changes: +HTTP-based services (Media-over-QUIC, WebRTC, HLS, Control API, Playback Server, Metrics, pprof) can be exposed in a subfolder of an external HTTP server or reverse proxy. The reverse proxy must be able to intercept HTTP requests addressed to _MediaMTX_ and corresponding responses, and must perform the following changes: - The subfolder path must be stripped from request paths. For instance, if the server is exposed behind `/subpath` and the reverse proxy receives a request with path `/subpath/mystream/index.m3u8`, this has to be changed into `/mystream/index.m3u8`. - Any `Location` header in responses must be prefixed with the subfolder path. For instance, if the server is exposed behind `/subpath` and the server sends a response with `Location: /mystream/index.m3u8`, this has to be changed into `Location: /subfolder/mystream/index.m3u8`. -If _nginx_ is the reverse proxy, this can be achieved with the following configuration: +## Nginx + +When _Nginx_ is the reverse proxy, rules described above can be implemented with the following configuration: ``` location /subpath/ { @@ -15,7 +17,9 @@ location /subpath/ { } ``` -If _Apache HTTP Server_ is the reverse proxy, this can be achieved with the following configuration: +## Apache HTTP Server + +When _Apache HTTP Server_ is the reverse proxy, rules described above can be implemented with the following configuration: ``` @@ -25,7 +29,9 @@ If _Apache HTTP Server_ is the reverse proxy, this can be achieved with the foll ``` -If _Caddy_ is the reverse proxy, this can be achieved with the following configuration: +## Caddy + +When _Caddy_ is the reverse proxy, rules described above can be implemented with the following configuration: ``` :80 { diff --git a/docs/2-features/23-metrics.md b/docs/2-features/23-metrics.md index d3c30a00..91c473de 100644 --- a/docs/2-features/23-metrics.md +++ b/docs/2-features/23-metrics.md @@ -149,13 +149,18 @@ webrtc_sessions_outbound_bytes{id="[id]",path="[path]",remoteAddr="[remoteAddr]" webrtc_sessions_outbound_rtp_packets{id="[id]",path="[path]",remoteAddr="[remoteAddr]",state="[state]"} 123 webrtc_sessions_outbound_rtcp_packets{id="[id]",path="[path]",remoteAddr="[remoteAddr]",state="[state]"} 123 webrtc_sessions_outbound_frames_discarded{id="[id]",path="[path]",remoteAddr="[remoteAddr]",state="[state]"} 12 + +# MoQ sessions +moq_sessions{id="[id]",path="[path]",remoteAddr="[remoteAddr]",state="[state]"} 1 +moq_sessions_inbound_bytes{id="[id]",path="[path]",remoteAddr="[remoteAddr]",state="[state]"} 1234 +moq_sessions_outbound_bytes{id="[id]",path="[path]",remoteAddr="[remoteAddr]",state="[state]"} 187 ``` Bitrates are not provided directly as metrics because they can be computed from received and sent bytes by any metrics analyzer (i.e. Grafana). Metrics can be filtered by using HTTP query parameters: -- `type=[TYPE]`: show metrics of a certain type only. TYPE can be `paths`, `hls_sessions`, `hls_muxers`, `rtsp_conns`, `rtsp_sessions`, `rtsps_conns`, `rtsps_sessions`, `rtmp_conns`, `rtmps_conns`, `srt_conns`, `webrtc_sessions`. +- `type=[TYPE]`: show metrics of a certain type only. TYPE can be `paths`, `hls_sessions`, `hls_muxers`, `rtsp_conns`, `rtsp_sessions`, `rtsps_conns`, `rtsps_sessions`, `rtmp_conns`, `rtmps_conns`, `srt_conns`, `webrtc_sessions`, `moq_sessions`. - `path=[PATH]`: show metrics belonging to a specific path only - `hls_muxer=[PATH]`: show metrics belonging to a specific HLS muxer only - `hls_session=[ID]`: show metrics belonging to a specific HLS session only @@ -167,3 +172,4 @@ Metrics can be filtered by using HTTP query parameters: - `rtmps_conn=[ID]` show metrics belonging to a specific RTMPS connection only - `srt_conn=[ID]` show metrics belonging to a specific SRT connection only - `webrtc_session=[ID]` show metrics belonging to a specific WebRTC session only +- `moq_session=[ID]` show metrics belonging to a specific MoQ session only diff --git a/docs/2-features/25-srt-specific-features.md b/docs/2-features/25-srt-specific-features.md index eb035292..0bde873d 100644 --- a/docs/2-features/25-srt-specific-features.md +++ b/docs/2-features/25-srt-specific-features.md @@ -1,6 +1,6 @@ # SRT-specific features -SRT is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with SRT clients](../3-publish/01-srt-clients.md) and [Read with SRT clients](../4-read/01-srt.md). Features in this page are shared among both tasks. +SRT is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with SRT clients](../3-publish/02-srt-clients.md) and [Read with SRT clients](../4-read/02-srt.md). Features in this page are shared among both tasks. ## Standard stream ID syntax diff --git a/docs/2-features/26-webrtc-specific-features.md b/docs/2-features/26-webrtc-specific-features.md index 2b490644..ab8c86ec 100644 --- a/docs/2-features/26-webrtc-specific-features.md +++ b/docs/2-features/26-webrtc-specific-features.md @@ -1,6 +1,6 @@ # WebRTC-specific features -WebRTC is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with WebRTC clients](../3-publish/03-webrtc-clients.md) and [Read with WebRTC clients](../4-read/02-webrtc.md). Features in this page are shared among both tasks. +WebRTC is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with WebRTC clients](../3-publish/05-webrtc-clients.md) and [Read with WebRTC clients](../4-read/03-webrtc.md). Features in this page are shared among both tasks. ## Codec support in browsers diff --git a/docs/2-features/27-rtsp-specific-features.md b/docs/2-features/27-rtsp-specific-features.md index a2fd5dae..e400e3bf 100644 --- a/docs/2-features/27-rtsp-specific-features.md +++ b/docs/2-features/27-rtsp-specific-features.md @@ -1,6 +1,6 @@ # RTSP-specific features -RTSP is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with RTSP clients](../3-publish/05-rtsp-clients.md) and [Read with RTSP clients](../4-read/03-rtsp.md). Features in this page are shared among both tasks. +RTSP is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with RTSP clients](../3-publish/07-rtsp-clients.md) and [Read with RTSP clients](../4-read/04-rtsp.md). Features in this page are shared among both tasks. ## Transport protocols @@ -107,4 +107,4 @@ There are also the `rtsps+http`, `rtsp+ws`, `rtsps+ws` schemas to handle any var ## MPEG-TS inside RTSP -read [MPEG-TS inside RTSP](../3-publish/05-rtsp-clients.md#mpeg-ts-inside-rtsp) in the "Publish with RTSP clients" page. +read [MPEG-TS inside RTSP](../3-publish/07-rtsp-clients.md#mpeg-ts-inside-rtsp) in the "Publish with RTSP clients" page. diff --git a/docs/2-features/28-rtmp-specific-features.md b/docs/2-features/28-rtmp-specific-features.md index c5ea66d0..da913720 100644 --- a/docs/2-features/28-rtmp-specific-features.md +++ b/docs/2-features/28-rtmp-specific-features.md @@ -1,6 +1,6 @@ # RTMP-specific features -RTMP is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with RTMP clients](../3-publish/07-rtmp-clients.md) and [Read with RTMP clients](../4-read/04-rtmp.md). Features in this page are shared among both tasks. +RTMP is a protocol that can be used for publishing and reading streams. Regarding specific tasks, check out [Publish with RTMP clients](../3-publish/09-rtmp-clients.md) and [Read with RTMP clients](../4-read/05-rtmp.md). Features in this page are shared among both tasks. ## Encryption diff --git a/docs/3-publish/01-moq-clients.md b/docs/3-publish/01-moq-clients.md new file mode 100644 index 00000000..d476fa96 --- /dev/null +++ b/docs/3-publish/01-moq-clients.md @@ -0,0 +1,36 @@ +# Media-over-QUIC clients + +| | supported codecs | +| --------- | ------------------------- | +| **video** | AV1, VP9, VP8, H265, H264 | +| **audio** | Opus, MPEG-4 Audio (AAC) | + +Media-over-QUIC is a streaming protocol built upon cutting edge protocols (QUIC, HTTP3) and browser APIs (WebTransport, WebCodecs) that can be used to publish and read live media streams. It's slightly faster than WebRTC, has an advanced data recovery mechanism, it supports additional codecs (FLAC and future ones) and is less complicated to route. + +Media-over-QUIC has a wide range of features and variants, most of them in active development. We currently support the following: + +- We support `draft-18` of the [main specification](https://datatracker.ietf.org/doc/html/draft-ietf-moq-transport-18). +- We only support using Media-over-QUIC through browsers and in particular through the WebTransport API. We do not support using QUIC directly. +- We support the `PUBLISH` and `SUBSCRIBE` messages only, which are the ones meant to be used by a routing solution like _MediaMTX_. +- We use the MOQT Streaming Format (MSF) to advertise tracks, described in [this specification](https://datatracker.ietf.org/doc/html/draft-ietf-moq-msf-00). +- We use the Low Overhead Media Container (LOC) to ship frames, described in [this specification](https://datatracker.ietf.org/doc/draft-ietf-moq-loc/). +- We host web pages through a HTTP/2 listener and host the WebTransport endpoint through a HTTP/3 listener. This hybrid setup allows to use self-signed certificates, that are normally forbidden in pure HTTP/3. + +There are some server requirements: + +- HTTPS is mandatory. +- Clients must be able to access both the HTTP/2 listener (`:8892`) and the HTTP/3 listener (`:8892`), the latter of which runs over UDP. + +And there are some client (browser) requirements: + +- If the server certificate is self-signed, browser must support the [serverCertificatesHashes option](https://caniuse.com/mdn-api_webtransport_webtransport_options_servercertificatehashes_parameter) (all except iOS safari do). +- Browser must support [WebTransport](https://caniuse.com/webtransport) and [WebCodecs](https://caniuse.com/webcodecs) (all modern browsers do) +- When publishing tracks, the browser to support [MediaStreamTrackProcessor](https://caniuse.com/mdn-api_mediastreamtrackprocessor) (only Chrome does). + +You can publish a stream with Media-over-QUIC and a web browser by visiting: + +``` +https://localhost:8892/mystream/publish +``` + +The only clients that can currently publish with Media-over-QUIC are [Web browsers](16-web-browsers.md). diff --git a/docs/3-publish/01-srt-clients.md b/docs/3-publish/02-srt-clients.md similarity index 90% rename from docs/3-publish/01-srt-clients.md rename to docs/3-publish/02-srt-clients.md index c06ce85f..3a936259 100644 --- a/docs/3-publish/01-srt-clients.md +++ b/docs/3-publish/02-srt-clients.md @@ -18,4 +18,4 @@ If you need to use the standard stream ID syntax instead of the custom one in us If you want to publish a stream by using a client in listening mode (i.e. with `mode=listener` appended to the URL), read the next section. -Some clients that can publish with SRT are [FFmpeg](15-ffmpeg.md), [GStreamer](16-gstreamer.md), [OBS Studio](17-obs-studio.md). +Some clients that can publish with SRT are [FFmpeg](17-ffmpeg.md), [GStreamer](18-gstreamer.md), [OBS Studio](19-obs-studio.md). diff --git a/docs/3-publish/02-srt-cameras-and-servers.md b/docs/3-publish/04-srt-cameras-and-servers.md similarity index 100% rename from docs/3-publish/02-srt-cameras-and-servers.md rename to docs/3-publish/04-srt-cameras-and-servers.md diff --git a/docs/3-publish/03-webrtc-clients.md b/docs/3-publish/05-webrtc-clients.md similarity index 91% rename from docs/3-publish/03-webrtc-clients.md rename to docs/3-publish/05-webrtc-clients.md index 335bec1b..74fdc32c 100644 --- a/docs/3-publish/03-webrtc-clients.md +++ b/docs/3-publish/05-webrtc-clients.md @@ -23,4 +23,4 @@ Be aware that not all browsers can read any codec, check [Codec support in brows Depending on the network it might be difficult to establish a connection between server and clients, read [Solving WebRTC connectivity issues](../2-features/26-webrtc-specific-features.md#solving-webrtc-connectivity-issues). -Some clients that can publish with WebRTC and WHIP are [FFmpeg](15-ffmpeg.md), [GStreamer](16-gstreamer.md), [OBS Studio](17-obs-studio.md), [Unity](20-unity.md) and [Web browsers](14-web-browsers.md). +Some clients that can publish with WebRTC and WHIP are [FFmpeg](17-ffmpeg.md), [GStreamer](18-gstreamer.md), [OBS Studio](19-obs-studio.md), [Unity](22-unity.md) and [Web browsers](16-web-browsers.md). diff --git a/docs/3-publish/04-webrtc-servers.md b/docs/3-publish/06-webrtc-servers.md similarity index 93% rename from docs/3-publish/04-webrtc-servers.md rename to docs/3-publish/06-webrtc-servers.md index 34e49f8d..c7bdfe1f 100644 --- a/docs/3-publish/04-webrtc-servers.md +++ b/docs/3-publish/06-webrtc-servers.md @@ -14,7 +14,7 @@ paths: source: wheps://host:port/path ``` -If the remote server is a _MediaMTX_ instance, remember to add a `/whep` suffix after the stream name, since in _MediaMTX_ [it's part of the WHEP URL](../4-read/02-webrtc.md): +If the remote server is a _MediaMTX_ instance, remember to add a `/whep` suffix after the stream name, since in _MediaMTX_ [it's part of the WHEP URL](../4-read/03-webrtc.md): ```yml paths: diff --git a/docs/3-publish/05-rtsp-clients.md b/docs/3-publish/07-rtsp-clients.md similarity index 90% rename from docs/3-publish/05-rtsp-clients.md rename to docs/3-publish/07-rtsp-clients.md index 7e6c41bf..1344645e 100644 --- a/docs/3-publish/05-rtsp-clients.md +++ b/docs/3-publish/07-rtsp-clients.md @@ -14,7 +14,7 @@ rtsp://localhost:8554/mystream The resulting stream will be available on path `/mystream`. -Some clients that can publish with RTSP are [FFmpeg](15-ffmpeg.md), [GStreamer](16-gstreamer.md), [OBS Studio](17-obs-studio.md), [Python and OpenCV](18-python-opencv.md). +Some clients that can publish with RTSP are [FFmpeg](17-ffmpeg.md), [GStreamer](18-gstreamer.md), [OBS Studio](19-obs-studio.md), [Python and OpenCV](20-python-opencv.md). Advanced RTSP features and settings are described in [RTSP-specific features](../2-features/27-rtsp-specific-features.md). diff --git a/docs/3-publish/06-rtsp-cameras-and-servers.md b/docs/3-publish/08-rtsp-cameras-and-servers.md similarity index 100% rename from docs/3-publish/06-rtsp-cameras-and-servers.md rename to docs/3-publish/08-rtsp-cameras-and-servers.md diff --git a/docs/3-publish/07-rtmp-clients.md b/docs/3-publish/09-rtmp-clients.md similarity index 86% rename from docs/3-publish/07-rtmp-clients.md rename to docs/3-publish/09-rtmp-clients.md index fd7b7239..d8db32b6 100644 --- a/docs/3-publish/07-rtmp-clients.md +++ b/docs/3-publish/09-rtmp-clients.md @@ -13,4 +13,4 @@ rtmp://localhost/mystream The resulting stream will be available on path `/mystream`. -Some clients that can publish with RTMP are [FFmpeg](15-ffmpeg.md), [GStreamer](16-gstreamer.md) and [OBS Studio](17-obs-studio.md). +Some clients that can publish with RTMP are [FFmpeg](17-ffmpeg.md), [GStreamer](18-gstreamer.md) and [OBS Studio](19-obs-studio.md). diff --git a/docs/3-publish/08-rtmp-cameras-and-servers.md b/docs/3-publish/10-rtmp-cameras-and-servers.md similarity index 100% rename from docs/3-publish/08-rtmp-cameras-and-servers.md rename to docs/3-publish/10-rtmp-cameras-and-servers.md diff --git a/docs/3-publish/09-hls-cameras-and-servers.md b/docs/3-publish/11-hls-cameras-and-servers.md similarity index 100% rename from docs/3-publish/09-hls-cameras-and-servers.md rename to docs/3-publish/11-hls-cameras-and-servers.md diff --git a/docs/3-publish/10-mpeg-ts.md b/docs/3-publish/12-mpeg-ts.md similarity index 96% rename from docs/3-publish/10-mpeg-ts.md rename to docs/3-publish/12-mpeg-ts.md index ba9c5018..32cb91da 100644 --- a/docs/3-publish/10-mpeg-ts.md +++ b/docs/3-publish/12-mpeg-ts.md @@ -34,7 +34,7 @@ paths: source: udp+mpegts://0.0.0.0:1234?source=192.168.3.5 ``` -Some clients that can publish with UDP and MPEG-TS are [FFmpeg](15-ffmpeg.md) and [GStreamer](16-gstreamer.md). +Some clients that can publish with UDP and MPEG-TS are [FFmpeg](17-ffmpeg.md) and [GStreamer](18-gstreamer.md). Unix sockets are more efficient than UDP packets and can be used as transport by specifying the `unix+mpegts` scheme: diff --git a/docs/3-publish/11-rtp.md b/docs/3-publish/13-rtp.md similarity index 96% rename from docs/3-publish/11-rtp.md rename to docs/3-publish/13-rtp.md index e92086f9..66aa4ed9 100644 --- a/docs/3-publish/11-rtp.md +++ b/docs/3-publish/13-rtp.md @@ -27,4 +27,4 @@ paths: `rtpSDP` must contain a valid SDP, that is a description of the RTP session. -Some clients that can publish with UDP and MPEG-TS are [FFmpeg](15-ffmpeg.md) and [GStreamer](16-gstreamer.md). +Some clients that can publish with UDP and MPEG-TS are [FFmpeg](17-ffmpeg.md) and [GStreamer](18-gstreamer.md). diff --git a/docs/3-publish/12-raspberry-pi-cameras.md b/docs/3-publish/14-raspberry-pi-cameras.md similarity index 100% rename from docs/3-publish/12-raspberry-pi-cameras.md rename to docs/3-publish/14-raspberry-pi-cameras.md diff --git a/docs/3-publish/13-generic-webcams.md b/docs/3-publish/15-generic-webcams.md similarity index 100% rename from docs/3-publish/13-generic-webcams.md rename to docs/3-publish/15-generic-webcams.md diff --git a/docs/3-publish/14-web-browsers.md b/docs/3-publish/16-web-browsers.md similarity index 58% rename from docs/3-publish/14-web-browsers.md rename to docs/3-publish/16-web-browsers.md index a33a5d59..970b345a 100644 --- a/docs/3-publish/14-web-browsers.md +++ b/docs/3-publish/16-web-browsers.md @@ -1,6 +1,26 @@ # Web browsers -Web browsers can publish a stream to the server by using the [WebRTC protocol](03-webrtc-clients.md). Start the server and open the web page: +Web browsers can publish a stream to the server by acting as a [Media-over-QUIC client](01-moq-clients.md) or a [WebRTC client](05-webrtc-clients.md). + +## Media-over-QUIC + +Start the server and open the web page: + +``` +https://localhost:8892/mystream/publish +``` + +The resulting stream will be available on path `/mystream`. + +This web page can be embedded into another web page by using an iframe: + +```html + +``` + +## WebRTC + +Start the server and open the web page: ``` http://localhost:8889/mystream/publish diff --git a/docs/3-publish/15-ffmpeg.md b/docs/3-publish/17-ffmpeg.md similarity index 75% rename from docs/3-publish/15-ffmpeg.md rename to docs/3-publish/17-ffmpeg.md index 633150cd..9d4727fe 100644 --- a/docs/3-publish/15-ffmpeg.md +++ b/docs/3-publish/17-ffmpeg.md @@ -1,8 +1,8 @@ # FFmpeg -FFmpeg can publish a stream to the server by using the [RTSP](05-rtsp-clients.md), [RTMP](07-rtmp-clients.md), [MPEG-TS](10-mpeg-ts.md), [RTP](11-rtp.md), [SRT](01-srt-clients.md) and [WebRTC](03-webrtc-clients.md) protocols. The recommended one is RTSP. +FFmpeg can publish a stream to the server by acting as a [RTSP client](07-rtsp-clients.md), [RTMP client](09-rtmp-clients.md), [SRT client](02-srt-clients.md), [WebRTC client](05-webrtc-clients.md) or by sending [MPEG-TS packets](12-mpeg-ts.md) or [RTP packets](13-rtp.md). The recommended way is acting as a RTSP client. -## FFmpeg and RTSP +## FFmpeg as a RTSP client ```sh ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f rtsp rtsp://localhost:8554/mystream @@ -10,7 +10,7 @@ ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f rtsp rtsp://localhost:8554/mys The resulting stream will be available on path `/mystream`. -## FFmpeg and RTMP +## FFmpeg as a RTMP client ```sh ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f flv rtmp://localhost:1935/mystream @@ -36,7 +36,7 @@ ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \ ## FFmpeg and RTP over UDP -In _MediaMTX_ configuration, add a path with `source: udp+rtp://238.0.0.1:1234` and a valid `rtpSDP` (read [RTP](11-rtp.md)). Then: +In _MediaMTX_ configuration, add a path with `source: udp+rtp://238.0.0.1:1234` and a valid `rtpSDP` (read [RTP](13-rtp.md)). Then: ```sh ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \ @@ -44,13 +44,13 @@ ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \ -f rtp udp://238.0.0.1:1234?pkt_size=1316 ``` -## FFmpeg and SRT +## FFmpeg as a SRT client ```sh ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f mpegts 'srt://localhost:8890?streamid=publish:stream&pkt_size=1316' ``` -## FFmpeg and WebRTC +## FFmpeg as a WebRTC client ```sh ffmpeg -re -f lavfi -i testsrc=size=1280x720:rate=30 \ diff --git a/docs/3-publish/16-gstreamer.md b/docs/3-publish/18-gstreamer.md similarity index 81% rename from docs/3-publish/16-gstreamer.md rename to docs/3-publish/18-gstreamer.md index 51e0421d..89af78b1 100644 --- a/docs/3-publish/16-gstreamer.md +++ b/docs/3-publish/18-gstreamer.md @@ -1,8 +1,8 @@ # GStreamer -GStreamer can publish a stream to the server by using the [RTSP](05-rtsp-clients.md), [RTMP](07-rtmp-clients.md), [SRT](01-srt-clients.md), [MPEG-TS](10-mpeg-ts.md) and [WebRTC](03-webrtc-clients.md) protocols. The recommended one is RTSP. +GStreamer can publish a stream to the server by acting as a [RTSP client](07-rtsp-clients.md), [RTMP client](09-rtmp-clients.md), [SRT client](02-srt-clients.md), [WebRTC client](05-webrtc-clients.md) or by sending [MPEG-TS packets](12-mpeg-ts.md). The recommended way is acting as a RTSP client. -## GStreamer and RTSP +## GStreamer as a RTSP client ```sh gst-launch-1.0 rtspclientsink name=s location=rtsp://localhost:8554/mystream \ @@ -20,7 +20,7 @@ d.video_0 ! rtspclientsink location=rtsp://localhost:8554/mystream The resulting stream will be available on path `/mystream`. -## GStreamer and RTMP +## GStreamer as a RTMP client ```sh gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://localhost/stream \ @@ -28,7 +28,7 @@ videotestsrc ! video/x-raw,width=1280,height=720,format=I420 ! x264enc speed-pre audiotestsrc ! audioconvert ! avenc_aac ! mux. ``` -## GStreamer and SRT +## GStreamer as a SRT client ```sh gst-launch-1.0 -v mpegtsmux name=mux ! srtsink uri="srt://localhost:8890?streamid=publish:mystream&pkt_size=1316" \ @@ -46,7 +46,7 @@ videotestsrc ! video/x-raw,width=1280,height=720,format=I420 ! x264enc speed-pre audiotestsrc ! audioconvert ! avenc_aac ! mux. ``` -## GStreamer and WebRTC +## GStreamer as a WebRTC client Make sure that GStreamer version is at least 1.22, and that if the codec is H264, the profile is baseline. Use the `whipclientsink` element: diff --git a/docs/3-publish/17-obs-studio.md b/docs/3-publish/19-obs-studio.md similarity index 95% rename from docs/3-publish/17-obs-studio.md rename to docs/3-publish/19-obs-studio.md index ab3a1183..4cd0a14d 100644 --- a/docs/3-publish/17-obs-studio.md +++ b/docs/3-publish/19-obs-studio.md @@ -1,8 +1,8 @@ # OBS Studio -OBS Studio can publish streams to the server by using the [RTMP](07-rtmp-clients.md) and [WebRTC](03-webrtc-clients.md) protocols. The recommended one is RTMP. +OBS Studio can publish streams to the server by acting as a [RTMP client](09-rtmp-clients.md) or a [WebRTC client](05-webrtc-clients.md) protocols. The recommended way is acting as a RTMP client. -## OBS Studio and RTMP +## OBS Studio as a RTMP client ### Standard @@ -173,11 +173,11 @@ OBS Studio requires _MediaMTX_ to use a TLS certificate signed by a public certi certutil -addstore "Root" myca.crt ``` -## OBS Studio and WebRTC +## OBS Studio as a WebRTC client ### Standard -Recent versions of OBS Studio can also publish streams to the server with the [WebRTC / WHIP protocol](03-webrtc-clients.md) Use the following parameters: +Recent versions of OBS Studio can also publish streams to the server with the [WebRTC / WHIP protocol](05-webrtc-clients.md) Use the following parameters: - Service: `WHIP` - Server: `http://localhost:8889/mystream/whip` diff --git a/docs/3-publish/18-python-opencv.md b/docs/3-publish/20-python-opencv.md similarity index 96% rename from docs/3-publish/18-python-opencv.md rename to docs/3-publish/20-python-opencv.md index cb7dbfc8..e04adc0d 100644 --- a/docs/3-publish/18-python-opencv.md +++ b/docs/3-publish/20-python-opencv.md @@ -1,6 +1,6 @@ # Python and OpenCV -Python-based software can publish streams to the server with the OpenCV library and its GStreamer plugin, acting as a [RTSP client](05-rtsp-clients.md). OpenCV must be compiled with support for GStreamer, by following this procedure: +Python-based software can publish streams to the server with the OpenCV library and its GStreamer plugin, acting as a [RTSP client](07-rtsp-clients.md). OpenCV must be compiled with support for GStreamer, by following this procedure: ```sh sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-ugly gstreamer1.0-rtsp python3-dev python3-numpy diff --git a/docs/3-publish/19-golang.md b/docs/3-publish/21-golang.md similarity index 100% rename from docs/3-publish/19-golang.md rename to docs/3-publish/21-golang.md diff --git a/docs/3-publish/20-unity.md b/docs/3-publish/22-unity.md similarity index 98% rename from docs/3-publish/20-unity.md rename to docs/3-publish/22-unity.md index c730b370..45f32f60 100644 --- a/docs/3-publish/20-unity.md +++ b/docs/3-publish/22-unity.md @@ -1,6 +1,6 @@ # Unity -Software written with the Unity Engine can publish a stream to the server by using the [WebRTC protocol](03-webrtc-clients.md). +Software written with the Unity Engine can publish a stream to the server by acting as a [WebRTC client](05-webrtc-clients.md). Create a new Unity project or open an existing one. diff --git a/docs/4-read/01-moq.md b/docs/4-read/01-moq.md new file mode 100644 index 00000000..b79e8667 --- /dev/null +++ b/docs/4-read/01-moq.md @@ -0,0 +1,18 @@ +# Media-over-QUIC clients + +| | supported codecs | +| --------- | ------------------------------------------------------- | +| **video** | AV1, VP9, VP8, H265, H264 | +| **audio** | Opus, FLAC, MPEG-4 Audio (AAC), G711 (PCMA, PCMU), LPCM | + +Media-over-QUIC is a streaming protocol built upon cutting edge protocols (QUIC, HTTP3) and browser APIs (WebTransport, WebCodecs) that can be used to publish and read live media streams. It's slightly faster than WebRTC, has an advanced data recovery mechanism, it supports additional codecs (FLAC and future ones) and is less complicated to route. + +There are some limitations and requirements that are listed in [Publish with Media-over-QUIC clients](../3-publish/01-moq-clients.md). + +You can read a stream with Media-over-QUIC and a web browser by visiting: + +``` +https://localhost:8892/mystream/publish +``` + +The only clients that can currently read with Media-over-QUIC are [Web browsers](07-web-browsers.md). diff --git a/docs/4-read/01-srt.md b/docs/4-read/02-srt.md similarity index 89% rename from docs/4-read/01-srt.md rename to docs/4-read/02-srt.md index a40f419a..2fba8bc5 100644 --- a/docs/4-read/01-srt.md +++ b/docs/4-read/02-srt.md @@ -16,4 +16,4 @@ Replace `mystream` with the path name. If you need to use the standard stream ID syntax instead of the custom one in use by this server, read [Standard stream ID syntax](../2-features/25-srt-specific-features.md#standard-stream-id-syntax). -Some clients that can read with SRT are [FFmpeg](07-ffmpeg.md), [GStreamer](08-gstreamer.md) and [VLC](09-vlc.md). +Some clients that can read with SRT are [FFmpeg](08-ffmpeg.md), [GStreamer](09-gstreamer.md) and [VLC](10-vlc.md). diff --git a/docs/4-read/02-webrtc.md b/docs/4-read/03-webrtc.md similarity index 95% rename from docs/4-read/02-webrtc.md rename to docs/4-read/03-webrtc.md index a7a18081..e4ce2314 100644 --- a/docs/4-read/02-webrtc.md +++ b/docs/4-read/03-webrtc.md @@ -22,4 +22,4 @@ Be aware that not all browsers can read any codec, check [Codec support in brows Depending on the network it may be difficult to establish a connection between server and clients, read [Solving WebRTC connectivity issues](../2-features/26-webrtc-specific-features.md#solving-webrtc-connectivity-issues). -Some clients that can read with WebRTC and WHEP are [GStreamer](08-gstreamer.md), [Unity](13-unity.md) and [web browsers](06-web-browsers.md). +Some clients that can read with WebRTC and WHEP are [GStreamer](09-gstreamer.md), [Unity](14-unity.md) and [web browsers](07-web-browsers.md). diff --git a/docs/4-read/03-rtsp.md b/docs/4-read/04-rtsp.md similarity index 88% rename from docs/4-read/03-rtsp.md rename to docs/4-read/04-rtsp.md index c1c51270..46debc73 100644 --- a/docs/4-read/03-rtsp.md +++ b/docs/4-read/04-rtsp.md @@ -12,4 +12,4 @@ RTSP is a protocol that allows to publish and read streams. It supports several rtsp://localhost:8554/mystream ``` -Some clients that can read with RTSP are [FFmpeg](07-ffmpeg.md), [GStreamer](08-gstreamer.md) and [VLC](09-vlc.md). +Some clients that can read with RTSP are [FFmpeg](08-ffmpeg.md), [GStreamer](09-gstreamer.md) and [VLC](10-vlc.md). diff --git a/docs/4-read/04-rtmp.md b/docs/4-read/05-rtmp.md similarity index 86% rename from docs/4-read/04-rtmp.md rename to docs/4-read/05-rtmp.md index 108b10b0..c35b7916 100644 --- a/docs/4-read/04-rtmp.md +++ b/docs/4-read/05-rtmp.md @@ -11,4 +11,4 @@ RTMP is a protocol that allows to read and publish streams. It has been expanded rtmp://localhost/mystream ``` -Some clients that can read with RTMP are [FFmpeg](07-ffmpeg.md), [GStreamer](08-gstreamer.md) and [VLC](09-vlc.md). +Some clients that can read with RTMP are [FFmpeg](08-ffmpeg.md), [GStreamer](09-gstreamer.md) and [VLC](10-vlc.md). diff --git a/docs/4-read/05-hls.md b/docs/4-read/06-hls.md similarity index 96% rename from docs/4-read/05-hls.md rename to docs/4-read/06-hls.md index be12a930..aefcc92f 100644 --- a/docs/4-read/05-hls.md +++ b/docs/4-read/06-hls.md @@ -18,7 +18,7 @@ and can also be accessed without using the browsers, by software that supports t http://localhost:8888/mystream/index.m3u8 ``` -Some clients that can read with HLS are [FFmpeg](07-ffmpeg.md), [GStreamer](08-gstreamer.md), [VLC](09-vlc.md) and [web browsers](06-web-browsers.md). +Some clients that can read with HLS are [FFmpeg](08-ffmpeg.md), [GStreamer](09-gstreamer.md), [VLC](10-vlc.md) and [web browsers](07-web-browsers.md). _MediaMTX_ supports generating HLS in several variants (including Low-Latency mode), and provides various parameters to tune HLS generation. These are listed in the [configuration file](../5-references/1-configuration-file.md): diff --git a/docs/4-read/06-web-browsers.md b/docs/4-read/07-web-browsers.md similarity index 90% rename from docs/4-read/06-web-browsers.md rename to docs/4-read/07-web-browsers.md index fbf5e39e..55c7b0b7 100644 --- a/docs/4-read/06-web-browsers.md +++ b/docs/4-read/07-web-browsers.md @@ -1,9 +1,19 @@ # Web browsers -Web browsers can read a stream from the server with the [WebRTC](02-webrtc.md) and [HLS](05-hls.md) protocols, by accessing web pages hosted by the server. It is also possible to embed streams into an external website. +Web browsers can read a stream from the server with the [Media-over-QUIC](01-moq.md), [WebRTC](03-webrtc.md) and [HLS](06-hls.md) protocols, by accessing web pages hosted by the server. It is also possible to embed streams into an external website. ## Direct read +### Media-over-QUIC + +Visit the web page: + +``` +https://localhost:8892/mystream +``` + +Replace `mystream` with the path name. + ### WebRTC Visit the web page: @@ -28,6 +38,14 @@ Replace `mystream` with the path name. Live streams can be embedded into an external website by using the WebRTC or HLS protocol. Before embedding, check that the stream is ready and can be accessed with intended protocol by visiting web pages mentioned in the previous section. +### Media-over-QUIC in iframe + +The simplest way to embed a live stream in a web page, using the Media-over-QUIC protocol, consists in adding an ` +``` + ### WebRTC in iframe The simplest way to embed a live stream in a web page, using the WebRTC protocol, consists in adding an `