Skip to main content

Module encode

Module encode 

Source
Expand description

Encode captured video and publish it as a moq video track.

The output codec is selected via Codec (H.264 or H.265); see its docs for which backends cover each on this platform.

Entry points, high to low level:

  • publish_capture captures and publishes a webcam (turnkey).
  • Encoder encodes raw Frames you supply into Encoded access units, and Producer publishes those (bring your own frames). Build both for the same Codec.
  • Sink is an Encoder that owns the thread it runs on, for an encoder outliving a single thread’s stack (a shared object, an FFI handle, a task that migrates between workers).
  • Producer alone publishes frames you already encoded.

Options / Kind / Config configure them. The decode/consume counterpart (mirror of moq-audio’s consumer) lives in the sibling decode module.

rate holds the policy mapping a congestion-control bandwidth estimate onto the encoder’s bitrate, which publish_capture drives for you.

Modules§

rate
Rate control: turning a congestion-control bandwidth estimate into the bitrate the encoder should actually produce at.

Structs§

Config
Encoder configuration. width / height / framerate are the encoded output; input frames must already be at this resolution.
Encoded
One encoded video frame: a whole access unit in the codec’s wire framing (Annex-B with in-band parameter sets), plus the presentation time of the raw Frame it came from.
Encoder
Video encoder. Build one with Encoder::new, feed it raw Frames via encode, and publish the resulting Encoded access units through a Producer built for the same Codec.
Options
Source-agnostic encode knobs for publish_capture, where the geometry (width / height / framerate) comes from the capture source, not the caller. For the bring-your-own-frames Encoder path, where you must specify geometry, use Config instead.
Producer
Publishes encoded video frames as a moq track (avc3 / hev1 depending on the codec).
Sink
An Encoder confined to one thread, driven from anywhere.

Enums§

Codec
Output video codec. #[non_exhaustive] so new codecs can be added without breaking external matches.
Kind
Which encoder implementation to use. #[non_exhaustive] so new selection strategies can be added without breaking external matches.

Functions§

publish_capture
Capture a webcam and publish it as an on-demand video track.