From 40f699cf28784ead46b91719e87bb2be28f9a3d2 Mon Sep 17 00:00:00 2001 From: nbabcock Date: Sat, 18 Feb 2023 14:35:13 -0600 Subject: [PATCH] feat: add input argument alias --- examples/h265_transcode.rs | 4 ++-- src/command.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/h265_transcode.rs b/examples/h265_transcode.rs index 67dfe44..a31ae79 100644 --- a/examples/h265_transcode.rs +++ b/examples/h265_transcode.rs @@ -15,7 +15,7 @@ fn main() { // One instance decodes H265 to raw frames let mut input = FfmpegCommand::new() - .args(&["-i", input_path]) + .input(input_path) .rawvideo() .spawn() .unwrap(); @@ -37,7 +37,7 @@ fn main() { .args(&[ "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", "600x800", "-r", "30", ]) // note: should be possible to infer these params from the source input stream - .args(&["-i", "-"]) + .input("-") .args(&["-c:v", "libx265"]) .args(&["-y", "output/h265_overlay.mp4"]) .spawn() diff --git a/src/command.rs b/src/command.rs index fbdf66a..a7e91c9 100644 --- a/src/command.rs +++ b/src/command.rs @@ -15,6 +15,13 @@ pub struct FfmpegCommand { impl FfmpegCommand { //// Argument presets + /// Alias for `-i` argument, setting the input file path or URL. + pub fn input>(&mut self, value: S) -> &mut Self { + self.arg("-i"); + self.arg(value.as_ref()); + self + } + /// Generate a procedural test video. /// Equivalent to `ffmpeg -i lavfi -f testsrc` ///