ffrwd/moq

MoQ publish and subscribe as SQL. A COPY destination sends a query's encoded streams to a relay broadcast as fragmented MP4 with a hang catalog; a FROM relation reads one back, a row per rendition.

Category

Publishers & Encoders

License

Open Source

Status

Active

Languages

Rust, SQL

Media Formats

HANGCMAF

ffrwd/moq is a package for ffrwd, a media processing engine driven by SQL, that puts a MoQ relay on both ends of a query. It is the only entry in this directory where publishing to MoQ is a COPY destination and subscribing is a table you select from.

Publishing

publish is a COPY destination — the query’s streams leave the graph for a relay broadcast, encoded on the way out:

COPY (
SELECT f.video[1]
FROM input('film.mp4') f
) TO ffrwd.moq.publish('moqt://relay.example:4443', 'live/demo')

The relation is the broadcast: one row is one rendition, so a rendition ladder is one row per rung, and a value read once per row shapes each rung’s encoder separately.

Subscribing

subscribe is a FROM relation. The rows are the renditions, carrying the columns any manifest input has — height, width, bandwidth, codecs, name — so picking a rung is a WHERE clause:

COPY (
SELECT s.video[1]
FROM ffrwd.moq.subscribe(:'relay', :'broadcast') s
WHERE s.height = 720
) TO 'rung.mp4'

How media is packaged

Each stream is packaged as fragmented MP4 — one moof+mdat per frame, a new MoQ group at every keyframe — with AAC audio cut on frame edges about once a second. A catalog.json track names what the broadcast carries in the hang catalog schema: renditions keyed by name, each with its codec string, its geometry or sample rate, and its init segment in the entry. A hang player picks a rendition and plays it.

The first publish is held until the track gains a subscriber, because a MoQ subscription starts at the latest group and anything sent earlier would never be seen.

Install

Terminal window
ffrwd install ffrwd/moq

The modules are Rust compiled to wasm32-wasip2, running on the host’s udp and http capabilities, with QUIC carried over a WASI transport and the relay hostname resolved by DNS-over-HTTPS.

Which draft it speaks

Not stated, and not tagged here for that reason. The package does not implement MoQT itself — it depends on moq-net 0.2.15 from the moq.dev stack, so it speaks whatever that release speaks, and the drafts listed against moq.dev are the closest answer this directory can give.