Skip to main content

FilterGraph

Struct FilterGraph 

Source
pub struct FilterGraph { /* private fields */ }
Expand description

An FFmpeg libavfilter filter graph.

Constructed via FilterGraph::builder(). The underlying AVFilterGraph is initialised lazily on the first push call, deriving format information from the first frame.

§Examples

use ff_filter::FilterGraph;

let mut graph = FilterGraph::builder()
    .scale(1280, 720)
    .build()?;

// Push decoded frames in …
graph.push_video(0, &video_frame)?;

// … and pull filtered frames out.
while let Some(frame) = graph.pull_video()? {
    // use frame
}

Implementations§

Source§

impl FilterGraph

Source

pub fn builder() -> FilterGraphBuilder

Create a new builder.

Source

pub fn output_resolution(&self) -> Option<(u32, u32)>

Returns the output resolution produced by this graph’s scale filter step, if one was configured.

When multiple scale steps are chained, the last one’s dimensions are returned. Returns None when no scale step was added.

Source

pub fn push_video( &mut self, slot: usize, frame: &VideoFrame, ) -> Result<(), FilterError>

Push a video frame into input slot slot.

On the first call the filter graph is initialised using this frame’s format, resolution, and time base.

§Errors
Source

pub fn pull_video(&mut self) -> Result<Option<VideoFrame>, FilterError>

Pull the next filtered video frame, if one is available.

Returns None when the internal FFmpeg buffer is empty (EAGAIN) or at end-of-stream.

§Errors

Returns FilterError::ProcessFailed on an unexpected FFmpeg error.

Source

pub fn push_audio( &mut self, slot: usize, frame: &AudioFrame, ) -> Result<(), FilterError>

Push an audio frame into input slot slot.

On the first call the audio filter graph is initialised using this frame’s format, sample rate, and channel count.

§Errors
Source

pub fn pull_audio(&mut self) -> Result<Option<AudioFrame>, FilterError>

Pull the next filtered audio frame, if one is available.

Returns None when the internal FFmpeg buffer is empty (EAGAIN) or at end-of-stream.

§Errors

Returns FilterError::ProcessFailed on an unexpected FFmpeg error.

Trait Implementations§

Source§

impl Debug for FilterGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<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, 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.