Added very basic file verification

This commit is contained in:
Jamie Hardt
2020-11-22 21:07:16 -08:00
parent a5c55dbcf1
commit bebfa235e6
8 changed files with 836 additions and 802 deletions

2
Cargo.lock generated
View File

@@ -2,7 +2,7 @@
# It is not intended for manual editing.
[[package]]
name = "bwavfile"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"byteorder",
"encoding",

View File

@@ -1,6 +1,6 @@
[package]
name = "bwavfile"
version = "0.1.1"
version = "0.1.2"
authors = ["Jamie Hardt <jamiehardt@me.com>"]
edition = "2018"
license = "MIT"
@@ -16,4 +16,4 @@ keywords = ["audio", "broadcast", "multimedia","smpte"]
[dependencies]
byteorder = "1.3.4"
encoding = "0.2.33"
serde_json = "1.0.59" # for tests
serde_json = "1.0.59"

View File

@@ -103,7 +103,7 @@ impl<R: Read + Seek> Iterator for Parser<R> {
fn next(&mut self) -> Option<Event> {
let (event, next_state) = self.advance();
println!("{:?}", event);
//println!("{:?}", event);
self.state = next_state;
return event;
}

BIN
tests/.DS_Store vendored

Binary file not shown.

View File

@@ -3,6 +3,14 @@
mkdir -p media
cd media
touch error.wav
unzip ../arch_pt_media.zip
unzip ../arch_audacity_media.zip
unzip ../arch_ff_media.zip
rm -rf __MACOSX
# create a silent bext wave file with fixture metadata and a time refernce starting at
# one minute
#
@@ -40,10 +48,3 @@ cd media
# ffmpeg -y -f lavfi -i "anoisesrc=r=48000:a=0.5:c=pink:s=41879" -to 0.1 -ar 48000 -c:a pcm_f32le \
# -write_bext 1 \
# -metadata "description=float test file" ff_float.wav
touch error.wav
unzip ../arch_pt_media.zip
unzip ../arch_audacity_media.zip
unzip ../arch_ff_media.zip
rm -rf __MACOSX

View File

@@ -1,783 +0,0 @@
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 1,
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "1536000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_float.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "113344",
"bit_rate": "1813504",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNFpjYOIk",
"date": "2020-11-18",
"creation_time": "19:57:21",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A3224F7E7248000F0B04F71BFE13E00"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"duration_ts": 4418,
"duration": "0.100181",
"bit_rate": "705600",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/audacity_16bit.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100181",
"size": "9046",
"bit_rate": "722372",
"probe_score": 99,
"tags": {
"title": "Pink Noise 16bit",
"album": "Test Media",
"artist": "Jamie Hardt"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "6912000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_24bit_51.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "452910",
"bit_rate": "7246560",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNdlHDPIk",
"date": "2020-11-18",
"creation_time": "19:58:18",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A5D84B0E724800060654F71BFE13E00"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 2,
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "3072000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_float_stereo.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "210058",
"bit_rate": "3360928",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijN!1TjQIk",
"date": "2020-11-18",
"creation_time": "19:59:16",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A89B75FE724800012164F71BFE13E00"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 2,
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "2304000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_24bit_stereo.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "162058",
"bit_rate": "2592928",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNF9aoPIk",
"date": "2020-11-18",
"creation_time": "19:57:57",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A4E03D7E724800059E44F71BFE13E00"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 1,
"channel_layout": "mono",
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 4800,
"duration": "0.100000",
"bit_rate": "1536000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_float.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100000",
"size": "19924",
"bit_rate": "1593920",
"probe_score": 99,
"tags": {
"comment": "float test file",
"time_reference": "0",
"encoder": "Lavf58.29.100"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 4800,
"duration": "0.100000",
"bit_rate": "2304000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_bwav_stereo.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100000",
"size": "29522",
"bit_rate": "2361760",
"probe_score": 99,
"tags": {
"comment": "FFMPEG-generated stereo WAV file with bext metadata",
"encoded_by": "ffmpeg",
"originator_reference": "STEREO_WAVE_TEST",
"date": "2020-11-18",
"creation_time": "12:00:00",
"time_reference": "2880000",
"umid": "0x7FFFFFFFFFFFFFFF7FFFFFFFFFFFFFFF00000000000000000000000000000000",
"coding_history": "A:PCM,48K",
"encoder": "Lavf58.29.100"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 1,
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "1152000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_24bit.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "89344",
"bit_rate": "1429504",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNtnVOOIk",
"date": "2020-11-18",
"creation_time": "19:57:08",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A28BCD4E72480004F4A4F71BFE13E00"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 4800,
"duration": "0.100000",
"bit_rate": "6912000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_bwav_51.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100000",
"size": "87122",
"bit_rate": "6969760",
"probe_score": 99,
"tags": {
"comment": "FFMPEG-generated 5.1 WAV file with bext metadata",
"encoded_by": "ffmpeg",
"originator_reference": "5_1_WAVE_TEST",
"date": "2020-11-18",
"creation_time": "13:00:00",
"time_reference": "0",
"umid": "0x7FFFFFFFFFFFFFFF7FFFFFFFFFFFFFFF00000000000000000000000000000000",
"coding_history": "A:PCM,48K",
"encoder": "Lavf58.29.100"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/96000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "96000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/96000",
"duration_ts": 259200000,
"duration": "2700.000000",
"bit_rate": "13824000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_longfile.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "2700.000000",
"size": "4665600748",
"bit_rate": "13824002",
"probe_score": 100,
"tags": {
"comment": "rf64 test file",
"time_reference": "0",
"encoder": "Lavf58.29.100"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "9216000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_float_51.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "596910",
"bit_rate": "9550560",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNViK8PIk",
"date": "2020-11-18",
"creation_time": "19:58:59",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A7C908BE724800047E94F71BFE13E00"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"duration_ts": 44100,
"duration": "1.000000",
"bit_rate": "705600",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_minimal.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "1.000000",
"size": "88244",
"bit_rate": "705952",
"probe_score": 99
}
}
{
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"duration_ts": 44100,
"duration": "1.000000",
"bit_rate": "705600",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_silence.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "1.000000",
"size": "88278",
"bit_rate": "706224",
"probe_score": 99,
"tags": {
"encoder": "Lavf58.29.100"
}
}
}
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "48000",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "768000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_16bit.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "65344",
"bit_rate": "1045504",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNZdiDOIk",
"date": "2020-11-18",
"creation_time": "19:56:53",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A1D203CE7248000711E4F71BFE13E00"
}
}
}

View File

@@ -1,17 +1,50 @@
extern crate serde_json;
use serde_json::{Result, Value, from_str};
use core::fmt::Debug;
use serde_json::{Value, from_str};
use std::fs::File;
use std::io::Read;
#[test]
fn test_a() {
let mut json_file = File::open("tests/ffprobe_media_results.json").unwrap();
use bwavfile::WaveReader;
// This seems rickety but we're going with it
fn assert_match_stream<T>(stream_key: &str,
other: impl Fn(&mut WaveReader<File>) -> T)
where T: PartialEq + Debug,
T: Into<Value>
{
let mut json_file = File::open("tests/media_ffprobe_result.json").unwrap();
let mut s = String::new();
json_file.read_to_string(&mut s).unwrap();
let v: Value = from_str(&mut s).unwrap();
//println!("file list: {:?}", ffprobe_data);
if let Value::Array(v) = from_str(&mut s).unwrap() { /* */
v.iter()
.filter(|value| {
!value["format"]["filename"].is_null()
})
.for_each(|value| {
let filen : &str = value["format"]["filename"].as_str().unwrap();
let json_value : &Value = &value["streams"][0][stream_key];
let mut wavfile = WaveReader::open(filen).unwrap();
let wavfile_value: T = other(&mut wavfile);
println!("asserting {} for {}",stream_key, filen);
assert_eq!(Into::<Value>::into(wavfile_value), *json_value);
})
}
}
#[test]
fn test_frame_count() {
assert_match_stream("duration_ts", |w| w.frame_length().unwrap() );
}
#[test]
fn test_sample_rate() {
assert_match_stream("sample_rate", |w| format!("{}", w.format().unwrap().sample_rate) );
}
#[test]
fn test_channel_count() {
assert_match_stream("channels", |w| w.format().unwrap().channel_count );
}

View File

@@ -0,0 +1,783 @@
[
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 1,
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "1536000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_float.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "113344",
"bit_rate": "1813504",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNFpjYOIk",
"date": "2020-11-18",
"creation_time": "19:57:21",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A3224F7E7248000F0B04F71BFE13E00"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"duration_ts": 4418,
"duration": "0.100181",
"bit_rate": "705600",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/audacity_16bit.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100181",
"size": "9046",
"bit_rate": "722372",
"probe_score": 99,
"tags": {
"title": "Pink Noise 16bit",
"album": "Test Media",
"artist": "Jamie Hardt"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "6912000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_24bit_51.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "452910",
"bit_rate": "7246560",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNdlHDPIk",
"date": "2020-11-18",
"creation_time": "19:58:18",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A5D84B0E724800060654F71BFE13E00"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 2,
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "3072000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_float_stereo.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "210058",
"bit_rate": "3360928",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijN!1TjQIk",
"date": "2020-11-18",
"creation_time": "19:59:16",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A89B75FE724800012164F71BFE13E00"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 2,
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "2304000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_24bit_stereo.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "162058",
"bit_rate": "2592928",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNF9aoPIk",
"date": "2020-11-18",
"creation_time": "19:57:57",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A4E03D7E724800059E44F71BFE13E00"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 1,
"channel_layout": "mono",
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 4800,
"duration": "0.100000",
"bit_rate": "1536000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_float.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100000",
"size": "19924",
"bit_rate": "1593920",
"probe_score": 99,
"tags": {
"comment": "float test file",
"time_reference": "0",
"encoder": "Lavf58.29.100"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 4800,
"duration": "0.100000",
"bit_rate": "2304000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_bwav_stereo.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100000",
"size": "29522",
"bit_rate": "2361760",
"probe_score": 99,
"tags": {
"comment": "FFMPEG-generated stereo WAV file with bext metadata",
"encoded_by": "ffmpeg",
"originator_reference": "STEREO_WAVE_TEST",
"date": "2020-11-18",
"creation_time": "12:00:00",
"time_reference": "2880000",
"umid": "0x7FFFFFFFFFFFFFFF7FFFFFFFFFFFFFFF00000000000000000000000000000000",
"coding_history": "A:PCM,48K",
"encoder": "Lavf58.29.100"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 1,
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "1152000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_24bit.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "89344",
"bit_rate": "1429504",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNtnVOOIk",
"date": "2020-11-18",
"creation_time": "19:57:08",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A28BCD4E72480004F4A4F71BFE13E00"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "48000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 4800,
"duration": "0.100000",
"bit_rate": "6912000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_bwav_51.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.100000",
"size": "87122",
"bit_rate": "6969760",
"probe_score": 99,
"tags": {
"comment": "FFMPEG-generated 5.1 WAV file with bext metadata",
"encoded_by": "ffmpeg",
"originator_reference": "5_1_WAVE_TEST",
"date": "2020-11-18",
"creation_time": "13:00:00",
"time_reference": "0",
"umid": "0x7FFFFFFFFFFFFFFF7FFFFFFFFFFFFFFF00000000000000000000000000000000",
"coding_history": "A:PCM,48K",
"encoder": "Lavf58.29.100"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s24le",
"codec_long_name": "PCM signed 24-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/96000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s32",
"sample_rate": "96000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 24,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/96000",
"duration_ts": 259200000,
"duration": "2700.000000",
"bit_rate": "13824000",
"bits_per_raw_sample": "24",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_longfile.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "2700.000000",
"size": "4665600748",
"bit_rate": "13824002",
"probe_score": 100,
"tags": {
"comment": "rf64 test file",
"time_reference": "0",
"encoder": "Lavf58.29.100"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_f32le",
"codec_long_name": "PCM 32-bit floating point little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[3][0][0][0]",
"codec_tag": "0x0003",
"sample_fmt": "flt",
"sample_rate": "48000",
"channels": 6,
"channel_layout": "5.1",
"bits_per_sample": 32,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "9216000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_float_51.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "596910",
"bit_rate": "9550560",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNViK8PIk",
"date": "2020-11-18",
"creation_time": "19:58:59",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A7C908BE724800047E94F71BFE13E00"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"duration_ts": 44100,
"duration": "1.000000",
"bit_rate": "705600",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_minimal.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "1.000000",
"size": "88244",
"bit_rate": "705952",
"probe_score": 99
}
},
{},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"duration_ts": 44100,
"duration": "1.000000",
"bit_rate": "705600",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/ff_silence.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "1.000000",
"size": "88278",
"bit_rate": "706224",
"probe_score": 99,
"tags": {
"encoder": "Lavf58.29.100"
}
}
},
{
"streams": [
{
"index": 0,
"codec_name": "pcm_s16le",
"codec_long_name": "PCM signed 16-bit little-endian",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "[1][0][0][0]",
"codec_tag": "0x0001",
"sample_fmt": "s16",
"sample_rate": "48000",
"channels": 1,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"duration_ts": 24000,
"duration": "0.500000",
"bit_rate": "768000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
}
],
"format": {
"filename": "tests/media/pt_16bit.wav",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "wav",
"format_long_name": "WAV / WAVE (Waveform Audio)",
"duration": "0.500000",
"size": "65344",
"bit_rate": "1045504",
"probe_score": 99,
"tags": {
"encoded_by": "Pro Tools",
"originator_reference": "aaijNZdiDOIk",
"date": "2020-11-18",
"creation_time": "19:56:53",
"time_reference": "1036416000",
"umid": "0x060A2B340101010501010F10130000002A1D203CE7248000711E4F71BFE13E00"
}
}
}
]