From 0e94a55751a4a6c34881ae4c0951552b4a02cea5 Mon Sep 17 00:00:00 2001 From: Redzic Date: Thu, 7 Jul 2022 15:43:41 -0500 Subject: [PATCH] Remove extra quotes and spaces from custom args --- av1an-cli/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/av1an-cli/src/lib.rs b/av1an-cli/src/lib.rs index 916c28ca..43d0b8cd 100644 --- a/av1an-cli/src/lib.rs +++ b/av1an-cli/src/lib.rs @@ -528,6 +528,11 @@ pub(crate) fn resolve_file_paths(path: &Path) -> anyhow::Result &str { + s.trim_matches(|c: char| c.is_whitespace() || c == '"' || c == '\'') +} + /// Returns vector of Encode args ready to be fed to encoder pub fn parse_cli(args: CliOpts) -> anyhow::Result> { let input_paths = &*args.input; @@ -557,7 +562,8 @@ pub fn parse_cli(args: CliOpts) -> anyhow::Result> { Path::new(&temp).join("log.log") }, ffmpeg_filter_args: if let Some(args) = args.ffmpeg_filter_args.as_ref() { - shlex::split(args).ok_or_else(|| anyhow!("Failed to split ffmpeg filter arguments"))? + shlex::split(remove_extra_chars(args)) + .ok_or_else(|| anyhow!("Failed to split ffmpeg filter arguments"))? } else { Vec::new() }, @@ -569,7 +575,8 @@ pub fn parse_cli(args: CliOpts) -> anyhow::Result> { args.encoder.get_default_pass() }, video_params: if let Some(args) = args.video_params.as_ref() { - shlex::split(args).ok_or_else(|| anyhow!("Failed to split video encoder arguments"))? + shlex::split(remove_extra_chars(args)) + .ok_or_else(|| anyhow!("Failed to split video encoder arguments"))? } else { Vec::new() }, @@ -595,7 +602,7 @@ pub fn parse_cli(args: CliOpts) -> anyhow::Result> { ) }, audio_params: if let Some(args) = args.audio_params.as_ref() { - shlex::split(args) + shlex::split(remove_extra_chars(args)) .ok_or_else(|| anyhow!("Failed to split ffmpeg audio encoder arguments"))? } else { into_vec!["-c:a", "copy"]