pub struct RealtimeComposer { /* private fields */ }Expand description
Composites externally-decoded frames from several layers into one frame, reusing a single built filter graph across frames.
Build once with new; then per output frame,
push_layer one frame for every layer and
pull the composited result. The output frame is
rgba. The graph (and any lut3d file its effects load) is built once, so it
is suitable for real-time playback.
Implementations§
Source§impl RealtimeComposer
impl RealtimeComposer
Sourcepub fn new(layers: &[RealtimeLayer]) -> Result<Self, FilterError>
pub fn new(layers: &[RealtimeLayer]) -> Result<Self, FilterError>
Builds a compositor for the given layers (at least one required).
§Errors
Returns FilterError::CompositionFailed when layers is empty or the
underlying FFmpeg graph cannot be built.
Sourcepub fn with_canvas(
layers: &[RealtimeLayer],
canvas: Option<(u32, u32)>,
) -> Result<Self, FilterError>
pub fn with_canvas( layers: &[RealtimeLayer], canvas: Option<(u32, u32)>, ) -> Result<Self, FilterError>
Like new, but composites onto a project canvas of
canvas = (width, height) pixels: every layer, the base included, is placed
in canvas pixels by its x / y / scale / rotation (ADR-0016), and the
output is exactly canvas-sized. A base whose frames are not canvas-sized sits
at its native size from the top-left; framing against the canvas is a
FitMode effect, never implicit. None uses the base layer’s own size as the
canvas (identical to new).
§Errors
Returns FilterError::CompositionFailed when layers is empty or the
underlying FFmpeg graph cannot be built.
Sourcepub fn layer_count(&self) -> usize
pub fn layer_count(&self) -> usize
Number of layers (== number of input slots).
Sourcepub fn push_layer(
&mut self,
idx: usize,
frame: &VideoFrame,
) -> Result<(), FilterError>
pub fn push_layer( &mut self, idx: usize, frame: &VideoFrame, ) -> Result<(), FilterError>
Pushes one frame into layer idx’s input slot.
Push exactly one frame per layer before each pull. The
frame must match the layer’s declared width/height/pixel format.
§Errors
Returns FilterError::InvalidInput if idx is not a layer slot, and the
graph’s error if the frame cannot be pushed. After a push error the composer’s
current tick is incomplete and it must be rebuilt.
Sourcepub fn pull(&mut self) -> Result<Option<VideoFrame>, FilterError>
pub fn pull(&mut self) -> Result<Option<VideoFrame>, FilterError>
Pulls the next composited frame (rgba), or None if not yet available.
§Errors
Returns FilterError on an unexpected FFmpeg error.