From a93440e06b4533689beae4dd6b07767db300757a Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Fri, 14 Oct 2022 14:40:26 +0200 Subject: [PATCH] fix case when video has no audio, but separate audio is set. add test case for it --- lib/src/filter/mod.rs | 1 + tests/src/engine_cmd.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/src/filter/mod.rs b/lib/src/filter/mod.rs index 287e9844..63b655ea 100644 --- a/lib/src/filter/mod.rs +++ b/lib/src/filter/mod.rs @@ -429,6 +429,7 @@ pub fn filter_chains( .as_ref() .and_then(|p| p.audio_streams.get(i as usize)) .is_some() + || Path::new(&node.audio).is_file() { extend_audio(node, &mut filters, i); } else if !node.is_live.unwrap_or(false) { diff --git a/tests/src/engine_cmd.rs b/tests/src/engine_cmd.rs index 1e9f5170..ce78874c 100644 --- a/tests/src/engine_cmd.rs +++ b/tests/src/engine_cmd.rs @@ -97,6 +97,40 @@ fn dual_audio_input() { assert_eq!(media.filter, test_filter_cmd); } +#[test] +fn video_separate_audio_input() { + let mut config = PlayoutConfig::new(Some("../assets/ffplayout.yml".to_string())); + config.out.mode = Stream; + config.processing.audio_tracks = 1; + config.processing.add_logo = false; + + let mut media_obj = Media::new(0, "./assets/no_audio.mp4", true); + media_obj.audio = "./assets/audio.mp3".to_string(); + let media = gen_source(&config, media_obj, &Arc::new(Mutex::new(vec![]))); + + let test_filter_cmd = Some(vec_strings![ + "-filter_complex", + "[0:v:0]scale=1024:576[vout0];[1:a:0]anull[aout0]", + "-map", + "[vout0]", + "-map", + "[aout0]" + ]); + + assert_eq!( + media.cmd, + Some(vec_strings![ + "-i", + "./assets/no_audio.mp4", + "-i", + "./assets/audio.mp3", + "-t", + "30" + ]) + ); + assert_eq!(media.filter, test_filter_cmd); +} + #[test] fn video_audio_stream() { let mut config = PlayoutConfig::new(Some("../assets/ffplayout.yml".to_string()));