Merge pull request #207 from jb-alvarado/master

fix case when video has no audio, but separate audio is set. add test case for it
This commit is contained in:
jb-alvarado 2022-10-14 14:50:09 +02:00 committed by GitHub
commit a7086498c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 0 deletions

View File

@ -429,6 +429,7 @@ pub fn filter_chains(
.as_ref() .as_ref()
.and_then(|p| p.audio_streams.get(i as usize)) .and_then(|p| p.audio_streams.get(i as usize))
.is_some() .is_some()
|| Path::new(&node.audio).is_file()
{ {
extend_audio(node, &mut filters, i); extend_audio(node, &mut filters, i);
} else if !node.is_live.unwrap_or(false) { } else if !node.is_live.unwrap_or(false) {

View File

@ -97,6 +97,40 @@ fn dual_audio_input() {
assert_eq!(media.filter, test_filter_cmd); 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] #[test]
fn video_audio_stream() { fn video_audio_stream() {
let mut config = PlayoutConfig::new(Some("../assets/ffplayout.yml".to_string())); let mut config = PlayoutConfig::new(Some("../assets/ffplayout.yml".to_string()));