Struct FfmpegChild

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

A wrapper around tokio::process::Child containing a spawned Ffmpeg command. Provides interfaces for reading parsed metadata, progress updates, warnings and errors and piped output frames if applicable.

Implementations§

Source§

impl FfmpegChild

Source

pub fn stream(&mut self) -> Result<FfmpegEventStream>

Crates a stream over events emitted by Ffmpeg. Functions similarly to Lines from tokio::io::BufReader, but providing a variety of parsed events:

  • Log messages
  • Parsed metadata
  • Progress updates
  • Errors and warnings
  • Raw output frames
Examples found in repository?
examples/test_exit.rs (line 13)
5async fn main() {
6  let mut child = FfmpegCommand::new()
7    .arg("-report")
8    .testsrc()
9    .rawvideo()
10    .print_command()
11    .spawn()
12    .unwrap();
13  let count = child.stream().unwrap().filter_progress().count().await;
14
15  assert!(count <= 1);
16}
Source

pub fn take_stdout(&mut self) -> Option<ChildStdout>

Escape hatch to manually control the process’ stdout channel. Calling this method takes ownership of the stdout channel, so the iterator will no longer include output frames in the stream of events.

Source

pub fn take_stderr(&mut self) -> Option<ChildStderr>

Escape hatch to manually control the process’ stderr channel. This method is mutually exclusive with events_iter, which relies on the stderr channel to parse events.

Source

pub fn take_stdin(&mut self) -> Option<ChildStdin>

Escape hatch to manually control the process’ stdin channel. This method is mutually exclusive with send_stdin_command and quit, which use the stdin channel to send commands to ffmpeg.

Source

pub async fn send_stdin_command(&mut self, command: &[u8]) -> Result<()>

Send a command to ffmpeg over stdin, used during interactive mode.

This method does not validate that the command is expected or handled correctly by ffmpeg. The returned io::Result indicates only whether the command was successfully sent or not.

In a typical ffmpeg build, these are the supported commands:

?      show this help
+      increase verbosity
-      decrease verbosity
c      Send command to first matching filter supporting it
C      Send/Queue command to all matching filters
D      cycle through available debug modes
h      dump packets/hex press to cycle through the 3 states
q      quit
s      Show QP histogram
Source

pub async fn quit(&mut self) -> Result<()>

Send a q command to ffmpeg over stdin, requesting a graceful shutdown as soon as possible.

This method returns after the command has been sent; the actual shut down may take a few more frames as ffmpeg flushes its buffers and writes the trailer, if applicable.

Source

pub async fn kill(&mut self) -> Result<()>

Forcibly terminate the inner child process.

Alternatively, you may choose to gracefully stop the child process by sending a command over stdin, using the quit method.

Identical to kill in std::process::Child.

Source

pub async fn wait(&mut self) -> Result<ExitStatus>

Waits for the inner child process to finish execution.

Identical to wait in std::process::Child.

Source

pub fn as_inner(&mut self) -> &Child

Escape hatch to access the inner Child.

Source

pub fn as_inner_mut(&mut self) -> &mut Child

Escape hatch to mutably access the inner Child.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,