2023-05-24 20:29:18 +00:00
# Media over QUIC
2022-06-29 16:17:02 +00:00
2023-05-24 20:29:18 +00:00
Media over QUIC (MoQ) is a live media delivery protocol utilizing QUIC streams.
See the [Warp draft ](https://datatracker.ietf.org/doc/draft-lcurley-warp/ ).
2022-06-29 16:17:02 +00:00
2023-05-24 20:29:18 +00:00
This repository is a Rust server that supports both contribution (ingest) and distribution (playback).
It requires a client, such as [moq-js ](https://github.com/kixelated/moq-js ).
2022-06-29 16:17:02 +00:00
2023-05-25 00:20:44 +00:00
## Setup
2022-06-30 20:23:33 +00:00
2023-05-25 00:20:44 +00:00
### Media
2023-05-24 20:29:18 +00:00
2022-06-29 16:30:55 +00:00
This demo simulates a live stream by reading a file from disk and sleeping based on media timestamps. Obviously you should hook this up to a real live stream to do anything useful.
2022-06-29 16:17:02 +00:00
2023-05-25 00:20:44 +00:00
Download your favorite media file and convert it to fragmented MP4.
This requires [ffmpeg ](https://ffmpeg.org/ )
2023-05-24 20:29:18 +00:00
2022-06-29 16:17:02 +00:00
```
2022-11-08 13:18:35 +00:00
wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -O media/source.mp4
2023-05-24 20:29:18 +00:00
./media/generate
2022-06-29 16:17:02 +00:00
```
2023-05-25 00:20:44 +00:00
### Certificates
2023-05-24 20:29:18 +00:00
2022-06-29 16:17:02 +00:00
Unfortunately, QUIC mandates TLS and makes local development difficult.
2023-05-16 17:23:50 +00:00
If you have a valid certificate you can use it instead of self-signing.
2022-06-29 16:17:02 +00:00
2023-05-25 00:20:44 +00:00
Use [mkcert ](https://github.com/FiloSottile/mkcert ) to generate a self-signed certificate.
Unfortunately, this currently requires Go in order to [fork ](https://github.com/FiloSottile/mkcert/pull/513 ) the tool.
2023-05-24 20:29:18 +00:00
2022-06-29 16:17:02 +00:00
```
2023-05-24 20:29:18 +00:00
./cert/generate
2022-06-29 16:17:02 +00:00
```
2023-05-25 00:20:44 +00:00
Unfortunately, WebTransport in Chrome currently (May 2023) doesn't verify certificates using the root CA.
The workaround is to use the `serverFingerprints` options, which requires the certificate MUST be only valid for at most **14 days** .
This is also why we're using a fork of mkcert, because it generates certificates valid for years by default.
This limitation will be removed once Chrome uses the system CA for WebTransport.
2022-06-29 16:17:02 +00:00
2023-05-25 00:20:44 +00:00
## Usage
2022-06-29 16:17:02 +00:00
2023-05-25 00:20:44 +00:00
Run the server:
2022-06-29 16:17:02 +00:00
```
2023-05-24 20:29:18 +00:00
cargo run
2022-06-29 16:17:02 +00:00
```
2023-05-24 20:29:18 +00:00
This listens for WebTransport connections on `https://localhost:4443` by default.
Use a [MoQ client ](https://github.com/kixelated/moq-js ) to connect to the server.