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
impl FilterGraph
Sourcepub fn builder() -> FilterGraphBuilder
pub fn builder() -> FilterGraphBuilder
Create a new builder.
Sourcepub fn push_video(
&mut self,
slot: usize,
frame: &VideoFrame,
) -> Result<(), FilterError>
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
FilterError::InvalidInputifslotis out of range.FilterError::BuildFailedif the graph cannot be initialised.FilterError::ProcessFailedif theFFmpegpush fails.
Sourcepub fn pull_video(&mut self) -> Result<Option<VideoFrame>, FilterError>
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.
Sourcepub fn push_audio(
&mut self,
slot: usize,
frame: &AudioFrame,
) -> Result<(), FilterError>
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
FilterError::InvalidInputifslotis out of range.FilterError::BuildFailedif the graph cannot be initialised.FilterError::ProcessFailedif theFFmpegpush fails.
Sourcepub fn pull_audio(&mut self) -> Result<Option<AudioFrame>, FilterError>
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.