| 1 | |
| 2 | |
| 3 | use std::io::Cursor; |
| 4 | use std::process::Command; |
| 5 | |
| 6 | use ec_core::{CodecId, Demuxer, MediaParameters}; |
| 7 | use ec_riff::AviDemuxer; |
| 8 | |
| 9 | #[test] |
| 10 | fn avi_tag_0x2001_is_dts() { |
| 11 | let out = std::env::temp_dir().join(format!("ec-riff-dts-{}.avi", std::process::id())); |
| 12 | let ok = Command::new("ffmpeg") |
| 13 | .args(["-v", "error", "-y", "-f", "lavfi", "-i"]) |
| 14 | .arg("sine=frequency=440:sample_rate=48000:duration=0.5") |
| 15 | .args(["-ac", "2", "-c:a", "dca", "-strict", "-2"]) |
| 16 | .arg(&out) |
| 17 | .output() |
| 18 | .is_ok_and(|o| o.status.success()); |
| 19 | if !ok { |
| 20 | assert!( |
| 21 | std::env::var_os("EC_REQUIRE_FIXTURES").is_none_or(|v| v.is_empty() || v == "0"), |
| 22 | "ffmpeg cannot make a DTS avi" |
| 23 | ); |
| 24 | eprintln!("skip: no ffmpeg with the dca encoder"); |
| 25 | return; |
| 26 | } |
| 27 | let bytes = std::fs::read(&out).unwrap(); |
| 28 | let _ = std::fs::remove_file(out); |
| 29 | let d = AviDemuxer::new(Cursor::new(bytes)).unwrap(); |
| 30 | let s = d.streams().iter().find(|s| s.params.codec == CodecId::Dts); |
| 31 | let s = s.expect("a DTS stream"); |
| 32 | let MediaParameters::Audio(a) = &s.params.media else { |
| 33 | panic!("not audio"); |
| 34 | }; |
| 35 | assert_eq!((a.sample_rate, a.layout.channel_count()), (48_000, 2)); |
| 36 | } |