pub struct MultiTrackComposer { /* private fields */ }Expand description
Composes multiple video layers onto a solid-colour canvas.
Layers are sorted by VideoLayer::z_order before compositing. The
resulting FilterGraph is source-only — call FilterGraph::pull_video
in a loop to extract the output frames. The graph terminates when the
last (highest z_order) layer finishes.
§Examples
ⓘ
use ff_filter::{AnimatedValue, MultiTrackComposer, VideoLayer};
use std::time::Duration;
let mut graph = MultiTrackComposer::new(1920, 1080)
.add_layer(VideoLayer {
source: "clip.mp4".into(),
x: AnimatedValue::Static(0.0),
y: AnimatedValue::Static(0.0),
scale_x: AnimatedValue::Static(1.0),
scale_y: AnimatedValue::Static(1.0),
rotation: AnimatedValue::Static(0.0),
opacity: AnimatedValue::Static(1.0),
z_order: 0,
time_offset: Duration::ZERO,
in_point: None,
out_point: None,
})
.build()?;
while let Some(frame) = graph.pull_video()? {
// encode or display `frame`
}Implementations§
Source§impl MultiTrackComposer
impl MultiTrackComposer
Sourcepub fn new(canvas_width: u32, canvas_height: u32) -> Self
pub fn new(canvas_width: u32, canvas_height: u32) -> Self
Creates a new composer with a black canvas and no layers.
Sourcepub fn background(self, rgb: Rgb) -> Self
pub fn background(self, rgb: Rgb) -> Self
Sets the canvas background colour and returns the updated composer.
Sourcepub fn add_layer(self, layer: VideoLayer) -> Self
pub fn add_layer(self, layer: VideoLayer) -> Self
Appends a video layer and returns the updated composer.
Sourcepub fn build(self) -> Result<FilterGraph, FilterError>
pub fn build(self) -> Result<FilterGraph, FilterError>
Builds a source-only FilterGraph that composites all layers.
§Errors
FilterError::CompositionFailed— canvas width or height is zero, no layers were added, or an underlyingFFmpeggraph-construction call failed.
Auto Trait Implementations§
impl Freeze for MultiTrackComposer
impl RefUnwindSafe for MultiTrackComposer
impl Send for MultiTrackComposer
impl Sync for MultiTrackComposer
impl Unpin for MultiTrackComposer
impl UnsafeUnpin for MultiTrackComposer
impl UnwindSafe for MultiTrackComposer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more