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-24 20:29:18 +00:00
## Requirements
2022-06-30 20:23:33 +00:00
2023-05-24 20:29:18 +00:00
- _Chrome_ : currently (May 2023) the only browser to support both WebTransport and WebCodecs.
- _yarn_ : required to install dependencies.
2022-06-30 20:23:33 +00:00
2022-06-29 16:30:55 +00:00
## Requirements
2023-05-24 20:29:18 +00:00
- _rust_ : duh
- _ffmpeg_ : (optional) used to generate fragmented media
- _go_ : (optional) used to generate self-signed certificates
- _openssl_ : (options) ...also used to generate self-signed certificates
2022-06-29 16:17:02 +00:00
2022-06-29 16:30:55 +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-24 20:29:18 +00:00
Download your favorite media file and convert it to fragmented MP4, by default `media/fragmented.mp4` :
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-16 17:23:50 +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-03-28 05:36:30 +00:00
Otherwise, we use [mkcert ](https://github.com/FiloSottile/mkcert ) to install a self-signed CA:
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-24 20:29:18 +00:00
With no arguments, the server will generate self-signed cert using this root CA.
This certificate is only valid for _2 weeks_ due to how WebTransport performs certificate fingerprinting.
2022-06-29 16:17:02 +00:00
2022-06-29 16:30:55 +00:00
## Server
2022-06-29 16:17:02 +00:00
2023-05-24 20:29:18 +00:00
`The Warp server supports WebTransport, pushing media over streams once a connection has been established.
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.