Skip to main content

FilterGraphBuilder

Struct FilterGraphBuilder 

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

Builder for constructing a FilterGraph.

Create one with FilterGraph::builder(), chain the desired filter methods, then call build to obtain the graph.

§Examples

use ff_filter::{FilterGraph, ToneMap};

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

Implementations§

Source§

impl FilterGraphBuilder

Source

pub fn new() -> Self

Creates an empty builder.

Source

pub fn trim(self, start: f64, end: f64) -> Self

Trim the stream to the half-open interval [start, end) in seconds.

Source

pub fn scale(self, width: u32, height: u32) -> Self

Scale the video to width × height pixels.

Source

pub fn crop(self, x: u32, y: u32, width: u32, height: u32) -> Self

Crop a rectangle starting at (x, y) with the given dimensions.

Source

pub fn overlay(self, x: i32, y: i32) -> Self

Overlay a second input stream at position (x, y).

Source

pub fn fade_in(self, duration: Duration) -> Self

Fade in from black over the given duration.

Source

pub fn fade_out(self, duration: Duration) -> Self

Fade out to black over the given duration.

Source

pub fn rotate(self, degrees: f64) -> Self

Rotate the video clockwise by degrees.

Source

pub fn tone_map(self, algorithm: ToneMap) -> Self

Apply HDR-to-SDR tone mapping using the given algorithm.

Source

pub fn volume(self, gain_db: f64) -> Self

Adjust audio volume by gain_db decibels (negative = quieter).

Source

pub fn amix(self, inputs: usize) -> Self

Mix inputs audio streams together.

Source

pub fn equalizer(self, band_hz: f64, gain_db: f64) -> Self

Apply a parametric equalizer band at band_hz Hz with gain_db dB.

Source

pub fn hardware(self, hw: HwAccel) -> Self

Enable hardware-accelerated filtering.

When set, hwupload and hwdownload filters are inserted around the filter chain automatically.

Source

pub fn build(self) -> Result<FilterGraph, FilterError>

Build the FilterGraph.

§Errors

Returns FilterError::BuildFailed if steps is empty (there is nothing to filter). The actual FFmpeg graph is constructed lazily on the first push_video or push_audio call.

Trait Implementations§

Source§

impl Debug for FilterGraphBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FilterGraphBuilder

Source§

fn default() -> FilterGraphBuilder

Returns the “default value” for a type. 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.