Skip to content

Rust library for Media over QUIC

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

kixelated/moq-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Media over QUIC

Media over QUIC (MoQ) is a live media delivery protocol utilizing QUIC. It's a client-server model that is designed to scale to enormous viewership via clustered relay servers (aka a CDN). The application determines the trade-off between latency and quality, potentially on a per viewer-basis.

See quic.video for more information. Note: this project is a fork of the IETF draft to speed up development.

The project is split into a few crates:

  • moq-relay: A server that forwards content from publishers to any interested subscribers. It can optionally be clustered, allowing N servers to transfer between themselves.
  • moq-web: A web client utilizing Rust and WASM. Supports both consuming media (and soon publishing).
  • moq-transfork: The underlying network protocol. It can be used by live applications that need real-time and scale, even if they're not media.
  • moq-karp: The underlying media protocol powered by moq-transfork. It includes a CLI for importing/exporting to other formats, for example integrating with ffmpeg.
  • moq-gst: A gstreamer plugin for producing Karp broadcasts. Note: ffmpeg is supported via moq-karp directly.
  • moq-clock: A dumb clock client/server just to prove MoQ can be used for more than media.
  • moq-native: Helpers to configure the native MoQ tools.

There are additional components that have been split into other repositories for development reasons:

Usage

Requirements

Development

There's a few scripts in the dev directory to help you get started:

# Run the relay, publisher, and web server:
npm install
npm run all

# Or use docker instead:
docker-compose up --build

Then, visit https://localhost:8080 to watch the simple demo.

Components

moq-relay

moq-relay is a server that forwards subscriptions from publishers to subscribers, caching and deduplicating along the way. It's designed to be run in a datacenter, relaying media across multiple hops to deduplicate and improve QoS.

Notable arguments:

  • --bind <ADDR> Listen on this address, default: [::]:4443
  • --tls-cert <CERT> Use the certificate file at this path
  • --tls-key <KEY> Use the private key at this path
  • --announce <URL> Forward all announcements to this address, typically a root relay.

This listens for WebTransport connections on UDP https://localhost:4443 by default. You need a client to connect to that address, to both publish and consume media.

moq-web

moq-web is a web client that can consume media (and soon publish). It's available on NPM as both a JS library and web component.

For example:

<script type="module">
	import '@kixelated/moq/video'
</script>

<moq-video src="https://relay.quic.video/demo/bbb"></moq-video>

The package is a gross frankenstein of Rust+Typescript.

npm i
npm run web

You can also test the package locally by linking. Replace npm with your favorite package manager (ex. pnpm, yarn, bun); it might work.

npm run pack
npm link

# In your other package
npm link @kixelated/moq

See the moq-web README for more information.

moq-karp

moq-karp is a simple media layer on top of MoQ. The crate includes a binary that accepts fMP4 with a few restrictions:

  • separate_moof: Each fragment must contain a single track.
  • frag_keyframe: A keyframe must be at the start of each keyframe.
  • fragment_per_frame: (optional) Each frame should be a separate fragment to minimize latency.

This can be used in conjunction with ffmpeg to publish media to a MoQ relay. See dev/pub for the required ffmpeg flags.

Alternatively, see moq-gst for a gstreamer plugin.

moq-transfork

A media-agnostic library used by moq-relay and moq-karp to serve the underlying subscriptions. It has caching/deduplication built-in, so your application is oblivious to the number of connections under the hood.

See the published crate and documentation.

moq-clock

moq-clock is a simple client that can publish or subscribe to the current time. It's meant to demonstate that moq-transfork can be used for more than just media.

nix/nixos

moq also has nix support see nix/README.md

License

Licensed under either: