Installation
Package Information
- Version: 0.2.0
- License: MIT OR Apache-2.0
- Repository: github:moq-dev/moq
- Dependencies:
@moq/lite,@moq/signals,zod, libavjs polyfill, SVTA CML
Overview
Hang provides the media layer for MoQ, handling:- Catalog: JSON track describing available media tracks and their codec properties
- Container: Encoding/decoding of timestamped codec bitstreams
- WebCodecs Integration: Work with VideoEncoder, AudioEncoder, VideoDecoder, AudioDecoder
Exports
Catalog- Catalog format for describing tracksContainer- Container format for framing codec dataMoq- Re-export of @moq/liteSignals- Re-export of @moq/signals
Catalog
The catalog is a JSON object describing the available tracks and their properties.Catalog Format
Publishing a Catalog
Reading a Catalog
Container
The container format handles timestamped codec bitstreams.Container Format
Each frame in the container consists of:- Timestamp (microseconds)
- Codec-specific bitstream data
Encoding Video Frames
Decoding Video Frames
Encoding Audio Frames
Decoding Audio Frames
WebCodecs Support
Hang is designed to work with the WebCodecs API:VideoEncoder/VideoDecoderAudioEncoder/AudioDecoderVideoFrame/AudioDataEncodedVideoChunk/EncodedAudioChunk
Supported Codecs
Video:- H.264 (avc1)
- H.265 (hev1)
- VP8
- VP9
- AV1
- Opus
- AAC
- FLAC
Utilities
Theutil export provides helper functions:
Browser Support
WebCodecs is supported in:- Chrome/Edge 94+
- Opera 80+
- Safari 16.4+ (limited codec support)
Node.js Support
For Node.js, use libavjs polyfill (automatically included):Complete Example
Here’s a complete example publishing video with catalog:Next Steps
@moq/watch
Use the watch component to display media
@moq/publish
Use the publish component to capture media
@moq/lite
Learn about the underlying protocol
WebCodecs API
Learn about WebCodecs