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_capturecaptures and publishes a webcam (turnkey), returning aPublicationthat reports its state and theDriverthat runs it. Requires thecapturefeature.Producerencodes rawFrames you supply and publishes them (bring your own frames), following the uplink’s bandwidth grant between frames. The counterpart ofmoq_audio::encode::Producer; the capture driver runs on it.Encoderencodes raw frames intoEncodedaccess units without publishing them.Sinkis anEncoderthat 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).Publisherpublishes frames you already encoded, with no rate control.
Both Producer and Publisher advertise their catalog rendition as soon
as the track exists, resolved from the encoder itself via Config::probe, so
a subscriber can discover a track nothing has encoded yet. That’s what lets an
on-demand capture wait for its first viewer at all.
Options / Capture (with capture) / Backend / Config configure
them. Config::preset picks a Preset, how the encoder trades latency
for compression at the configured bitrate. The decode/consume counterpart
(mirror of moq-audio’s consumer) lives in the sibling
decode module.
The shared moq_mux::rate policy maps a congestion-control bandwidth
estimate onto the encoder’s bitrate, which Producer drives for you.
Structs§
- Applied
- The latency and compression controls a backend actually applied at open.
- Capture
- Capture and encode settings for
publish_capture. - Config
- Encoder configuration.
width/height/framerateare the encoded output; external Vulkan frames are scaled by the backend on their GPU. - Driver
- The task that captures, encodes, and publishes one video track.
- 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
Frameit came from. - Encoder
- Video encoder. Build one with
Encoder::new, submit rawFrames viaencode,receivethe resultingEncodedaccess units until it returnsNone, and publish them through aPublisherbuilt for the sameCodec. - Finished
- A video track whose
ProducerorPublisherfinished it: every frame is published, and it can still be watched or aborted, but not written to. - Options
- Encode and publication policy for
Producer. - Producer
- Encode raw
Frames and publish them as a moq video track (avc3 / hev1 by codec). - Publication
- A handle that observes a capture publication.
- Publisher
- Publishes already-encoded video frames as a moq track (avc3 / hev1 depending on the codec), for a caller that runs its own encoder.
- Rendition
- A smaller rendition a
Capturescales from its frames, published asvideo/<name>. - Rung
- A rendition’s place in a simulcast ladder, from
Producer::rung, which the next rendition up takes as itsOptions::lower. - Sink
- An
Encoderconfined to one thread, driven from anywhere. - State
- A snapshot of a capture publication’s lifecycle.
Enums§
- Backend
- Which encoder implementation to use.
#[non_exhaustive]so new selection strategies can be added without breaking externalmatches. - Codec
- Output video codec.
#[non_exhaustive]so new codecs can be added without breaking externalmatches. - Preset
- How an encoder trades latency for compression at the configured bitrate.
- Status
- The capture publication’s current lifecycle state.
Constants§
- NAMES
- Every encoder backend this crate has a name for, on any platform.
Functions§
- publish_
capture - Capture a webcam and publish it as a video track, plus one per
Capture::renditions.