pub struct VideoWriter { /* private fields */ }Expand description
Pushes raw video frames from Rust code into a full FFmpeg pipeline. See the module documentation for the frame contract and teardown semantics.
Experimental: new in 0.14; the surface may still be refined.
Implementations§
Source§impl VideoWriter
impl VideoWriter
Sourcepub fn builder(width: u32, height: u32) -> VideoWriterBuilder
pub fn builder(width: u32, height: u32) -> VideoWriterBuilder
Starts a builder. Width and height are positional so they cannot be forgotten.
Sourcepub fn frame_size(&self) -> usize
pub fn frame_size(&self) -> usize
Exact number of bytes one frame must contain:
av_image_get_buffer_size(pix_fmt, width, height, 1) (tight packing).
Sourcepub fn write(&mut self, frame: &[u8]) -> Result<(), PushError>
pub fn write(&mut self, frame: &[u8]) -> Result<(), PushError>
Pushes one frame, copying the borrowed slice into an owned buffer. Blocks while the internal queue is full (backpressure).
Sourcepub fn write_owned(&mut self, frame: Vec<u8>) -> Result<(), PushError>
pub fn write_owned(&mut self, frame: Vec<u8>) -> Result<(), PushError>
Pushes one owned frame; the Vec is moved into the pipeline, saving
the borrow-copy that write performs. The pipeline
still copies the bytes once, plane-by-plane, into an aligned AVFrame
on the worker thread. frame.len() must equal
frame_size; the Vec is queued as-is, so any
spare capacity beyond its length stays allocated while it waits.
Sourcepub fn finish(self) -> Result<()>
pub fn finish(self) -> Result<()>
Closes ingress (the frame source emits its end-of-stream marker),
drains the encoder, finalizes the container, and returns the first
authoritative pipeline error. This is the result path — a write that
returned PushError::PipelineClosed resolves here, either to the
real cause or to Ok when the pipeline closed after completing
normally (e.g. an Output frame limit was reached).
Sourcepub fn abort(self)
pub fn abort(self)
Discards the export: drops ingress, then hard-aborts the scheduler. For “user cancelled” flows where the output is not wanted.
Caveat: abort() blocks until every worker releases its slot (no fixed
time bound) and may skip the encoder flush / muxer trailer, so the
partial file is not guaranteed playable. Use finish to
finalize.