Skip to main content

VideoWriter

Struct VideoWriter 

Source
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

Source

pub fn builder(width: u32, height: u32) -> VideoWriterBuilder

Starts a builder. Width and height are positional so they cannot be forgotten.

Source

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).

Source

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).

Source

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.

Source

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).

Source

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.

Trait Implementations§

Source§

impl Drop for VideoWriter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,