pub struct Frame {
pub timestamp: Timestamp,
pub duration: Option<Timestamp>,
pub payload: Bytes,
pub keyframe: bool,
}Expand description
A decoded media frame: timestamp, payload bytes, keyframe flag.
payload is the raw codec bitstream that gets handed to the decoder.
The exact shape depends on the codec (Annex B for H.264/H.265, OBU for
AV1, and so on).
Fields§
§timestamp: TimestampPresentation timestamp.
Each container picks its own native scale: fmp4 uses the source
mdhd.timescale, mkv uses nanoseconds, legacy is fixed at microseconds.
LOC defaults to microseconds but a decoded frame keeps whatever per-frame
timescale the wire carried, so an exporter can re-emit without forcing
micros. Frames within a track must be in decode order, not display
order. B-frames may have non-monotonic presentation timestamps.
duration: Option<Timestamp>Sample duration in the frame’s own scale, when the container reports it.
CMAF carries a per-sample duration (trun sample-duration); containers
that don’t (Legacy, LOC) leave this None. The Consumer adds it to
timestamp to learn how far a group has presented, so it can advance to
a newer group as soon as the gap is covered instead of waiting out the
latency budget.
payload: BytesEncoded codec payload.
keyframe: boolWhether this frame is a keyframe.
Containers that carry the bit on the wire (CMAF reads it from
trun sample-flags) should set it; containers that don’t (Legacy,
LOC) leave it false. The wrapping Consumer still asserts
“first frame in a group is a keyframe” as a fallback, so the
Legacy/LOC case lands correctly without anyone having to know.