btw: MoQ is under active development. The APIs and protocols are still evolving and will change. Most of this documentation is AI generated until things get more stable.

Skip to content

moq-mux

crates.iodocs.rsLicense: MIT

Media muxers and demuxers for converting existing media formats into MoQ broadcasts.

Overview

moq-mux provides tools for importing media from (and exporting it back to) various container formats:

  • fMP4/CMAF - Fragmented MP4 and Common Media Application Format
  • MPEG-TS - Transport stream (import and export)
  • Matroska / WebM - EBML container (import and export)
  • FLV - Flash Video / RTMP container (import and export). Legacy H.264 + AAC + MP3 plus the enhanced-RTMP FourCC codecs (HEVC, AV1, VP9, Opus, AC-3, E-AC-3), including enhanced-RTMP multitrack (several video/audio renditions in one stream)
  • Annex B - H.264/H.265 raw NAL unit streams

This crate is designed for ingesting existing content into the MoQ ecosystem, converting from traditional formats into hang broadcasts.

Installation

Add to your Cargo.toml:

toml
[dependencies]
moq-mux = "0.1"

Quick Start

Import fMP4

See the moq-cli source for real-world usage of moq-mux for importing fMP4 streams. Use moq-hls for HLS import and export.

Supported Codecs

Video:

  • H.264 (AVC)
  • H.265 (HEVC)
  • AV1
  • VP8
  • VP9

Audio:

  • AAC
  • Opus
  • MP3
  • MP2 (MPEG-TS only, carried verbatim)
  • AC-3 (MPEG-TS only, carried verbatim)
  • E-AC-3 (MPEG-TS only, carried verbatim)

Use Cases

  • Ingest existing content - Convert VOD files to MoQ broadcasts
  • Testing - Use sample files for development and testing
  • Migration - Transition from traditional streaming to MoQ

Integration with hang

moq-mux produces hang broadcasts with proper catalog and frame metadata. See the hang video example for how to publish a broadcast with proper catalog setup.

API Reference

Full API documentation: docs.rs/moq-mux

Key types:

  • Fmp4 - fMP4/CMAF importer
  • Fmp4Config - Configuration for fMP4 import
  • Decoder - Codec-specific decoders (AAC, Opus, AVC, HEVC)

CLI Tool

For command-line importing, use moq-cli:

bash
# Install
cargo install moq-cli

# Publish a video file (remux to MPEG-TS and pipe it in)
ffmpeg -i input.mp4 -c copy -f mpegts - | \
    moq --client-connect https://relay.example.com/anon --broadcast my-stream import ts

# Publish from FFmpeg
ffmpeg -i input.mp4 -f mpegts - | \
    moq --client-connect https://relay.example.com/anon --broadcast my-stream import ts

Next Steps

Licensed under MIT or Apache-2.0