pub struct Frame {
pub timestamp: Timestamp,
pub decode: Option<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.
decode: Option<Timestamp>Decode timestamp, when it differs from timestamp, or None when the
frame decodes at its presentation time.
A decode-order container writes each frame to the transport at
its decode time and groups by it: raw, which therefore refuses a reordered frame, and
cts, which this build still only reads (a decoded cts frame reports it). Other
containers ignore it: they carry the presentation time in the payload and stamp the
transport with the newest one so far in the group, since a group’s timestamps never
decrease.
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). Legacy and LOC
can fill it from a duration marker that has already landed when a
GroupConsumer reads the frame, as in a fetched group. Streaming
muxers receive the later endpoint separately, so media stays immediately available.
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 max delay budget.
payload: BytesEncoded codec payload.
keyframe: boolWhether this frame opens a group, or is a video keyframe.
Containers that carry the bit on the wire (CMAF reads it from
trun sample-flags) set it for video; 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. For
audio, whose samples are all independently decodable, that fallback
is the only source: the bit marks the group boundary the publisher
drew, never a per-sample sync flag.