mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-01 09:20:40 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41b599923a | ||
|
|
ae09897abf | ||
|
|
d37726f090 | ||
|
|
ae52152111 | ||
|
|
004249773a | ||
|
|
ebbdb99c46 | ||
|
|
32454039bf | ||
|
|
830c702376 | ||
|
|
0723f21e4f | ||
|
|
08743be3fa | ||
|
|
bdb39684c7 | ||
|
|
c3c3c12d38 |
@@ -3,11 +3,9 @@ python:
|
|||||||
- "3.6"
|
- "3.6"
|
||||||
- "3.5"
|
- "3.5"
|
||||||
- "3.4"
|
- "3.4"
|
||||||
- "3.3"
|
|
||||||
- "3.2"
|
|
||||||
- "3.1"
|
|
||||||
- "3.0"
|
|
||||||
script:
|
script:
|
||||||
- "python3 setup.py test"
|
- "python3 setup.py test"
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get install -y ffmpeg
|
||||||
install:
|
install:
|
||||||
- "pip3 install setuptools"
|
- "pip3 install setuptools"
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
[](https://travis-ci.com/iluvcapra/wavinfo)
|
|
||||||
[](https://wavinfo.readthedocs.io/en/latest/?badge=latest)   [](https://pypi.org/project/wavinfo/) 
|
[](https://wavinfo.readthedocs.io/en/latest/?badge=latest)   [](https://pypi.org/project/wavinfo/) 
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ This module is presently under construction and not sutiable for production at t
|
|||||||
|
|
||||||
[ebu]:https://tech.ebu.ch/docs/tech/tech3285.pdf
|
[ebu]:https://tech.ebu.ch/docs/tech/tech3285.pdf
|
||||||
[smpte_330m2011]:http://standards.smpte.org/content/978-1-61482-678-1/st-330-2011/SEC1.abstract
|
[smpte_330m2011]:http://standards.smpte.org/content/978-1-61482-678-1/st-330-2011/SEC1.abstract
|
||||||
[ixml]:http://www.ixml.infoi
|
[ixml]:http://www.ixml.info
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
104
demo.md
104
demo.md
@@ -1,104 +0,0 @@
|
|||||||
|
|
||||||
# `wavinfo` Demonstration
|
|
||||||
|
|
||||||
The entry point for wavinfo is the WavInfoReader class.
|
|
||||||
|
|
||||||
|
|
||||||
```python
|
|
||||||
from wavinfo import WavInfoReader
|
|
||||||
|
|
||||||
path = '../tests/test_files/A101_1.WAV'
|
|
||||||
|
|
||||||
info = WavInfoReader(path)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Basic WAV Data
|
|
||||||
|
|
||||||
The length of the file in frames (interleaved samples) and bytes is available, as is the contents of the format chunk.
|
|
||||||
|
|
||||||
|
|
||||||
```python
|
|
||||||
(info.data.frame_count, info.data.byte_count)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(240239, 1441434)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```python
|
|
||||||
(info.fmt.sample_rate, info.fmt.channel_count, info.fmt.block_align, info.fmt.bits_per_sample)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(48000, 2, 6, 24)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Broadcast WAV Extension
|
|
||||||
|
|
||||||
|
|
||||||
```python
|
|
||||||
print(info.bext.description)
|
|
||||||
print("----------")
|
|
||||||
print("Originator:", info.bext.originator)
|
|
||||||
print("Originator Ref:", info.bext.originator_ref)
|
|
||||||
print("Originator Date:", info.bext.originator_date)
|
|
||||||
print("Originator Time:", info.bext.originator_time)
|
|
||||||
print("Time Reference:", info.bext.time_reference)
|
|
||||||
print(info.bext.coding_history)
|
|
||||||
```
|
|
||||||
|
|
||||||
sSPEED=023.976-ND
|
|
||||||
sTAKE=1
|
|
||||||
sUBITS=$12311801
|
|
||||||
sSWVER=2.67
|
|
||||||
sPROJECT=BMH
|
|
||||||
sSCENE=A101
|
|
||||||
sFILENAME=A101_1.WAV
|
|
||||||
sTAPE=18Y12M31
|
|
||||||
sTRK1=MKH516 A
|
|
||||||
sTRK2=Boom
|
|
||||||
sNOTE=
|
|
||||||
|
|
||||||
----------
|
|
||||||
Originator: Sound Dev: 702T S#GR1112089007
|
|
||||||
Originator Ref: USSDVGR1112089007124001008206301
|
|
||||||
Originator Date: 2018-12-31
|
|
||||||
Originator Time: 12:40:00
|
|
||||||
Time Reference: 2190940753
|
|
||||||
A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## iXML Production Recorder Metadata
|
|
||||||
|
|
||||||
|
|
||||||
```python
|
|
||||||
print("iXML Project:", info.ixml.project)
|
|
||||||
print("iXML Scene:", info.ixml.scene)
|
|
||||||
print("iXML Take:", info.ixml.take)
|
|
||||||
print("iXML Tape:", info.ixml.tape)
|
|
||||||
print("iXML File Family Name:", info.ixml.family_name)
|
|
||||||
print("iXML File Family UID:", info.ixml.family_uid)
|
|
||||||
```
|
|
||||||
|
|
||||||
iXML Project: BMH
|
|
||||||
iXML Scene: A101
|
|
||||||
iXML Take: 1
|
|
||||||
iXML Tape: 18Y12M31
|
|
||||||
iXML File Family Name: None
|
|
||||||
iXML File Family UID: USSDVGR1112089007124001008206300
|
|
||||||
A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```python
|
|
||||||
|
|
||||||
```
|
|
||||||
@@ -25,86 +25,17 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"testfile_path = \"../tests/test_files/\"\n",
|
"path = '../tests/test_files/protools/PT A101_4.A1.wav'\n",
|
||||||
"sound_devices_file = testfile_path + \"A101_1.WAV\"\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"info = wavinfo.WavInfoReader(sound_devices_file)"
|
"info = wavinfo.WavInfoReader(path)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 4,
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
"outputs": [
|
"scrolled": true
|
||||||
{
|
},
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"WavInfoFormat(audio_format=1, channel_count=2, sample_rate=48000, byte_rate=288000, block_align=6, bits_per_sample=24)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"pp.pprint(info.fmt)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 5,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"WavBextFormat(description='sSPEED=023.976-ND\\r\\nsTAKE=1\\r\\nsUBITS=$12311801\\r\\nsSWVER=2.67\\r\\nsPROJECT=BMH\\r\\nsSCENE=A101\\r\\nsFILENAME=A101_1.WAV\\r\\nsTAPE=18Y12M31\\r\\nsTRK1=MKH516 A\\r\\nsTRK2=Boom\\r\\nsNOTE=\\r\\n', originator='Sound Dev: 702T S#GR1112089007', originator_ref='USSDVGR1112089007124001008206301', originator_date='2018-12-31', originator_time='12:40:00', time_reference=2190940753, version=1, umid=b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', loudness_value=0.0, loudness_range=0.0, max_true_peak=0.0, max_momentary_loudness=0.0, max_shortterm_loudness=0.0, coding_history='A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch\\r\\n')\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"pp.pprint(info.bext)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 6,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"('BMH', 'A101', '1', 240239)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 6,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"info.ixml.project, info.ixml.scene, info.ixml.take, info.data.frame_count"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 7,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"pro_tools_file = testfile_path + \"PT A101_4.A1.wav\""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 8,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
@@ -123,7 +54,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"import wavinfo.wave_parser\n",
|
"import wavinfo.wave_parser\n",
|
||||||
"\n",
|
"\n",
|
||||||
"with open(pro_tools_file,'rb') as f:\n",
|
"with open(path,'rb') as f:\n",
|
||||||
" chunk_tree = wavinfo.wave_parser.parse_chunk(f)\n",
|
" chunk_tree = wavinfo.wave_parser.parse_chunk(f)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"pp.pprint(chunk_tree.children)"
|
"pp.pprint(chunk_tree.children)"
|
||||||
@@ -131,73 +62,68 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": 5,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"WavBextFormat(description='dUBITS=12311804\\r\\ndSCENE=A101\\r\\ndTAKE=4\\r\\ndTAPE=18Y12M31\\r\\ndFRAMERATE=23.976ND\\r\\ndSPEED=023.976-NDF\\r\\ndTRK1=MKH516 A\\r\\ndTRK2=Boom\\r\\n', originator='Sound Dev: 702T S#GR1112089007', originator_ref='aa4CKtcd13Vk', originator_date='2018-12-31', originator_time='12:40:07', time_reference=2191709524, version=0, umid=b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', loudness_value=0.0, loudness_range=0.0, max_true_peak=0.0, max_momentary_loudness=0.0, max_shortterm_loudness=0.0, coding_history='A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch\\r\\n')\n"
|
"b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00*\\xfd\\xf5\\x0c$\\xe4s\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\n",
|
||||||
|
"000000000000002afdf50c24e47380000000000000000000\n",
|
||||||
|
"24\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"ptinfo = wavinfo.WavInfoReader(pro_tools_file)\n",
|
"with open(path,'rb') as f:\n",
|
||||||
"\n",
|
" f.seek( chunk_tree.children[4].start )\n",
|
||||||
"print(ptinfo.bext)"
|
" umid_bin = f.read(chunk_tree.children[4].length)\n",
|
||||||
|
" f.seek( chunk_tree.children[6].start )\n",
|
||||||
|
" regn_bin = f.read(chunk_tree.children[6].length)\n",
|
||||||
|
" \n",
|
||||||
|
"print(umid_bin)\n",
|
||||||
|
"print(umid_bin.hex())\n",
|
||||||
|
"print(len(umid_bin))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 10,
|
"execution_count": 6,
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"'<BWFXML><IXML_VERSION>1.61</IXML_VERSION><STEINBERG><ATTR_LIST><ATTR><TYPE>string</TYPE><NAME>MediaLibrary</NAME><VALUE>The Recordist Christmas 2018</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MediaCategoryPost</NAME><VALUE>Bullets</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MediaLibraryManufacturerName</NAME><VALUE>Creative Sound Design, LLC</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>AudioSoundEditor</NAME><VALUE>Frank Bry</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MediaComment</NAME><VALUE>BULLET Impact Plastic LCD TV Screen Shatter Debris 2x</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MusicalCategory</NAME><VALUE>Bullets</VALUE></ATTR></ATTR_LIST></STEINBERG></BWFXML>'"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 10,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"library_sound = testfile_path + 'BULLET Impact Plastic LCD TV Screen Shatter Debris 2x.wav'\n",
|
|
||||||
"\n",
|
|
||||||
"recinfo = wavinfo.WavInfoReader(library_sound)\n",
|
|
||||||
"\n",
|
|
||||||
"recinfo.ixml.source"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 11,
|
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[ ChunkDescriptor(ident=b'fmt ', start=20, length=40),\n",
|
"WavBextFormat(description='dUBITS=12311804\\r\\ndSCENE=A101\\r\\ndTAKE=4\\r\\ndTAPE=18Y12M31\\r\\ndFRAMERATE=23.976ND\\r\\ndSPEED=023.976-NDF\\r\\ndTRK1=MKH516 A\\r\\ndTRK2=Boom\\r\\n', originator='Sound Dev: 702T S#GR1112089007', originator_ref='aa4CKtcd13Vk', originator_date='2018-12-31', originator_time='12:40:07', time_reference=2191709524, version=0, umid=None, loudness_value=0.0, loudness_range=0.0, max_true_peak=0.0, max_momentary_loudness=0.0, max_shortterm_loudness=0.0, coding_history='A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch\\r\\n')\n"
|
||||||
" ChunkDescriptor(ident=b'bext', start=68, length=604),\n",
|
]
|
||||||
" ChunkDescriptor(ident=b'data', start=680, length=2833404),\n",
|
}
|
||||||
" ChunkDescriptor(ident=b'ID3 ', start=2834092, length=2048),\n",
|
],
|
||||||
" ChunkDescriptor(ident=b'SMED', start=2836148, length=5468),\n",
|
"source": [
|
||||||
" ListChunkDescriptor(signature=b'INFO', children=[ChunkDescriptor(ident=b'IPRD', start=2841636, length=30), ChunkDescriptor(ident=b'IGNR', start=2841674, length=8), ChunkDescriptor(ident=b'IART', start=2841690, length=10), ChunkDescriptor(ident=b'ICMT', start=2841708, length=54), ChunkDescriptor(ident=b'ICOP', start=2841770, length=84), ChunkDescriptor(ident=b'ISFT', start=2841862, length=12), ChunkDescriptor(ident=b'ICRD', start=2841882, length=12)]),\n",
|
"print(info.bext)"
|
||||||
" ChunkDescriptor(ident=b'iXML', start=2841902, length=686),\n",
|
]
|
||||||
" ChunkDescriptor(ident=b'umid', start=2842596, length=24),\n",
|
},
|
||||||
" ChunkDescriptor(ident=b'_PMX', start=2842628, length=3560)]\n"
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 8,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"b'\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00*\\xfd\\xf5\\x0c$\\xe4s\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x0c3\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00T\\xd5\\xa2\\x82\\x00\\x00\\x00\\x00\\x10PT A101_4.A1.wavGK\\xaa\\xaf\\x7f\\x00\\x00@ }\\x06\\x00`\\x00\\x00'\n",
|
||||||
|
"01000000000000000000002afdf50c24e473800000000000000000000c330200000000000000000000000000000000000000000054d5a2820000000010505420413130315f342e41312e776176474baaaf7f000040207d0600600000\n",
|
||||||
|
"92\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"with open(library_sound,'rb') as f:\n",
|
|
||||||
" chunk_tree = wavinfo.wave_parser.parse_chunk(f)\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"pp.pprint(chunk_tree.children)"
|
"print(regn_bin)\n",
|
||||||
|
"print(regn_bin.hex())\n",
|
||||||
|
"print(len(regn_bin))"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
2
pypi_upload.sh
Executable file
2
pypi_upload.sh
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
python3 -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
|
||||||
9
setup.py
9
setup.py
@@ -4,15 +4,18 @@ with open("README.md", "r") as fh:
|
|||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
|
|
||||||
setup(name='wavinfo',
|
setup(name='wavinfo',
|
||||||
version='0.1',
|
version='0.2',
|
||||||
author='Jamie Hardt',
|
author='Jamie Hardt',
|
||||||
author_email='jamiehardt@me.com',
|
author_email='jamiehardt@me.com',
|
||||||
description='WAVE sound file metadata parser.',
|
description='WAVE sound file metadata parser.',
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
url='https://github.com/iluvcapra/wavinfo',
|
url='https://github.com/iluvcapra/wavinfo',
|
||||||
classifiers=['Development Status :: 2 - Pre-Alpha',
|
classifiers=['Development Status :: 4 - Beta',
|
||||||
'License :: OSI Approved :: MIT License',
|
'License :: OSI Approved :: MIT License',
|
||||||
'Topic :: Multimedia',
|
'Topic :: Multimedia',
|
||||||
'Topic :: Multimedia :: Sound/Audio'],
|
'Topic :: Multimedia :: Sound/Audio',
|
||||||
|
"Programming Language :: Python :: 3.4",
|
||||||
|
"Programming Language :: Python :: 3.5",
|
||||||
|
"Programming Language :: Python :: 3.6"],
|
||||||
packages=['wavinfo'])
|
packages=['wavinfo'])
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
SOUND REPORT
|
SOUND REPORT
|
||||||
|
Can't render this file because it contains an unexpected character in line 1 and column 53.
|
BIN
tests/test_files/metacorder/Sr001-001-06_01.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-001-06_01.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-001-06_02.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-001-06_02.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-001-06_03.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-001-06_03.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-001-06_04.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-001-06_04.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-001-06_05.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-001-06_05.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-2C-01_01.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-2C-01_01.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-2C-01_02.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-2C-01_02.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-2C-01_03.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-2C-01_03.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-2C-01_04.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-2C-01_04.WAV
Normal file
Binary file not shown.
BIN
tests/test_files/metacorder/Sr001-2C-01_05.WAV
Normal file
BIN
tests/test_files/metacorder/Sr001-2C-01_05.WAV
Normal file
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from subprocess import PIPE
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ def ffprobe(path):
|
|||||||
|
|
||||||
arguments = [ FFPROBE , "-of", "json" , "-show_format", "-show_streams", path ]
|
arguments = [ FFPROBE , "-of", "json" , "-show_format", "-show_streams", path ]
|
||||||
|
|
||||||
process = subprocess.run(arguments, stdin=None, capture_output=True)
|
process = subprocess.run(arguments, stdin=None, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
return json.loads(process.stdout)
|
return json.loads(process.stdout)
|
||||||
@@ -28,7 +29,7 @@ class TestWaveInfo(TestCase):
|
|||||||
for dirpath, dirnames, filenames in os.walk('tests/test_files'):
|
for dirpath, dirnames, filenames in os.walk('tests/test_files'):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
name, ext = os.path.splitext(filename)
|
name, ext = os.path.splitext(filename)
|
||||||
if ext == '.wav':
|
if ext in ['.wav','.WAV']:
|
||||||
yield os.path.join(dirpath, filename)
|
yield os.path.join(dirpath, filename)
|
||||||
|
|
||||||
|
|
||||||
@@ -67,13 +68,20 @@ class TestWaveInfo(TestCase):
|
|||||||
|
|
||||||
self.assertEqual( info.bext.description, ffprobe_info['format']['tags']['comment'] )
|
self.assertEqual( info.bext.description, ffprobe_info['format']['tags']['comment'] )
|
||||||
self.assertEqual( info.bext.originator, ffprobe_info['format']['tags']['encoded_by'] )
|
self.assertEqual( info.bext.originator, ffprobe_info['format']['tags']['encoded_by'] )
|
||||||
self.assertEqual( info.bext.originator_ref, ffprobe_info['format']['tags']['originator_reference'] )
|
if 'originator_reference' in ffprobe_info['format']['tags']:
|
||||||
|
self.assertEqual( info.bext.originator_ref, ffprobe_info['format']['tags']['originator_reference'] )
|
||||||
|
else:
|
||||||
|
self.assertEqual( info.bext.originator_ref, '')
|
||||||
|
|
||||||
# these don't always reflect the bext info
|
# these don't always reflect the bext info
|
||||||
#self.assertEqual( info.bext.originator_date, ffprobe_info['format']['tags']['date'] )
|
#self.assertEqual( info.bext.originator_date, ffprobe_info['format']['tags']['date'] )
|
||||||
#self.assertEqual( info.bext.originator_time, ffprobe_info['format']['tags']['creation_time'] )
|
#self.assertEqual( info.bext.originator_time, ffprobe_info['format']['tags']['creation_time'] )
|
||||||
self.assertEqual( info.bext.time_reference, int(ffprobe_info['format']['tags']['time_reference']) )
|
self.assertEqual( info.bext.time_reference, int(ffprobe_info['format']['tags']['time_reference']) )
|
||||||
self.assertEqual( info.bext.coding_history, ffprobe_info['format']['tags']['coding_history'] )
|
|
||||||
|
if 'coding_history' in ffprobe_info['format']['tags']:
|
||||||
|
self.assertEqual( info.bext.coding_history, ffprobe_info['format']['tags']['coding_history'] )
|
||||||
|
else:
|
||||||
|
self.assertEqual( info.bext.coding_history, '' )
|
||||||
|
|
||||||
def test_ixml(self):
|
def test_ixml(self):
|
||||||
expected = {'A101_4.WAV': {'project' : 'BMH', 'scene': 'A101', 'take': '4',
|
expected = {'A101_4.WAV': {'project' : 'BMH', 'scene': 'A101', 'take': '4',
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class WavInfoReader():
|
|||||||
bits_per_sample = unpacked[5]
|
bits_per_sample = unpacked[5]
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_bext(self,f):
|
def _get_bext(self,f,encoding='ascii'):
|
||||||
|
|
||||||
bext_data = self._find_chunk_data(b'bext',f,default_none=True)
|
bext_data = self._find_chunk_data(b'bext',f,default_none=True)
|
||||||
|
|
||||||
@@ -117,20 +117,49 @@ class WavInfoReader():
|
|||||||
rest_starts = struct.calcsize(packstring)
|
rest_starts = struct.calcsize(packstring)
|
||||||
unpacked = struct.unpack(packstring, bext_data[:rest_starts])
|
unpacked = struct.unpack(packstring, bext_data[:rest_starts])
|
||||||
|
|
||||||
return WavBextFormat(description=unpacked[0].decode('ascii').rstrip('\0'),
|
def sanatize_bytes(bytes):
|
||||||
originator = unpacked[1].decode('ascii').rstrip('\0'),
|
first_null = next( (index for index, byte in enumerate(bytes) if byte == 0 ), None )
|
||||||
originator_ref = unpacked[2].decode('ascii').rstrip('\0'),
|
if first_null is not None:
|
||||||
originator_date = unpacked[3].decode('ascii'),
|
trimmed = bytes[:first_null]
|
||||||
originator_time = unpacked[4].decode('ascii'),
|
else:
|
||||||
|
trimmed = bytes
|
||||||
|
|
||||||
|
decoded = trimmed.decode(encoding)
|
||||||
|
return decoded
|
||||||
|
|
||||||
|
bext_version = unpacked[6]
|
||||||
|
if bext_version > 0:
|
||||||
|
umid = unpacked[6]
|
||||||
|
else:
|
||||||
|
umid = None
|
||||||
|
|
||||||
|
if bext_version > 1:
|
||||||
|
loudness_value = unpacked[8] / 100.0,
|
||||||
|
loudness_range = unpacked[9] / 100.0
|
||||||
|
max_true_peak = unpacked[10] / 100.0
|
||||||
|
max_momentary_loudness = unpacked[11] / 100.0
|
||||||
|
max_shortterm_loudness = unpacked[12] / 100.0
|
||||||
|
else:
|
||||||
|
loudness_value = None
|
||||||
|
loudness_range = None
|
||||||
|
max_true_peak = None
|
||||||
|
max_momentary_loudness = None
|
||||||
|
max_shortterm_loudness = None
|
||||||
|
|
||||||
|
return WavBextFormat(description=sanatize_bytes(unpacked[0]),
|
||||||
|
originator = sanatize_bytes(unpacked[1]),
|
||||||
|
originator_ref = sanatize_bytes(unpacked[2]),
|
||||||
|
originator_date = sanatize_bytes(unpacked[3]),
|
||||||
|
originator_time = sanatize_bytes(unpacked[4]),
|
||||||
time_reference = unpacked[5],
|
time_reference = unpacked[5],
|
||||||
version = unpacked[6],
|
version = unpacked[6],
|
||||||
umid = unpacked[7],
|
umid = umid,
|
||||||
loudness_value = unpacked[8] / 100.0,
|
loudness_value = loudness_value,
|
||||||
loudness_range = unpacked[9] / 100.0,
|
loudness_range = loudness_range,
|
||||||
max_true_peak = unpacked[10] / 100.0,
|
max_true_peak = max_true_peak,
|
||||||
max_momentary_loudness = unpacked[11] / 100.0,
|
max_momentary_loudness = max_momentary_loudness,
|
||||||
max_shortterm_loudness = unpacked[12] / 100.0,
|
max_shortterm_loudness = max_shortterm_loudness,
|
||||||
coding_history = bext_data[rest_starts:].decode('ascii').rstrip('\0')
|
coding_history = sanatize_bytes(bext_data[rest_starts:])
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_ixml(self,f):
|
def _get_ixml(self,f):
|
||||||
|
|||||||
Reference in New Issue
Block a user