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
impl FfmpegChild
Sourcepub fn stream(&mut self) -> Result<FfmpegEventStream>
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?
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}
Sourcepub fn take_stdout(&mut self) -> Option<ChildStdout>
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.
Sourcepub fn take_stderr(&mut self) -> Option<ChildStderr>
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.
Sourcepub fn take_stdin(&mut self) -> Option<ChildStdin>
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.
Sourcepub async fn send_stdin_command(&mut self, command: &[u8]) -> Result<()>
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
Sourcepub async fn quit(&mut self) -> Result<()>
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.
Sourcepub async fn kill(&mut self) -> Result<()>
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
.
Sourcepub async fn wait(&mut self) -> Result<ExitStatus>
pub async fn wait(&mut self) -> Result<ExitStatus>
Waits for the inner child process to finish execution.
Identical to wait
in std::process::Child
.
Sourcepub fn as_inner_mut(&mut self) -> &mut Child
pub fn as_inner_mut(&mut self) -> &mut Child
Escape hatch to mutably access the inner Child
.