12 Commits
v0.1 ... v0.2

Author SHA1 Message Date
Jamie Hardt
41b599923a bext Version handling 2019-01-01 20:51:54 -08:00
Jamie Hardt
ae09897abf Fixed bext parsing for metacorder
These have really screwed-up bext chunks that aren't zero-filled.
2019-01-01 19:30:43 -08:00
Jamie Hardt
d37726f090 Reorganized test WAVs into folders 2019-01-01 19:30:06 -08:00
Jamie Hardt
ae52152111 More test WAV files
From Gallery Metacorder
2019-01-01 13:44:56 -08:00
Jamie Hardt
004249773a Update README.md
Fixed ixml URL
2019-01-01 12:36:09 -08:00
Jamie Hardt
ebbdb99c46 Update README.md
Removed Travis badge
2019-01-01 12:25:05 -08:00
Jamie Hardt
32454039bf Trying to get travis build to work 2019-01-01 12:22:23 -08:00
Jamie Hardt
830c702376 Update .travis.yml
Removed other old versions
2019-01-01 12:21:05 -08:00
Jamie Hardt
0723f21e4f Update .travis.yml
Add ffprobe to apt-get (I hope)
2019-01-01 12:20:24 -08:00
Jamie Hardt
08743be3fa Update .travis.yml
Removed unavailable versions
2019-01-01 12:16:16 -08:00
Jamie Hardt
bdb39684c7 Update test_wave_parsing.py
Removed capture_output argument, it's too new
2019-01-01 12:15:17 -08:00
Jamie Hardt
c3c3c12d38 Nudge version 2019-01-01 12:09:03 -08:00
26 changed files with 109 additions and 248 deletions

View File

@@ -3,11 +3,9 @@ python:
- "3.6"
- "3.5"
- "3.4"
- "3.3"
- "3.2"
- "3.1"
- "3.0"
script:
- "python3 setup.py test"
before_install:
- sudo apt-get install -y ffmpeg
install:
- "pip3 install setuptools"

View File

@@ -1,4 +1,3 @@
[![Build Status](https://travis-ci.com/iluvcapra/wavinfo.svg?branch=master)](https://travis-ci.com/iluvcapra/wavinfo)
[![Documentation Status](https://readthedocs.org/projects/wavinfo/badge/?version=latest)](https://wavinfo.readthedocs.io/en/latest/?badge=latest) ![](https://img.shields.io/github/license/iluvcapra/wavinfo.svg) ![](https://img.shields.io/pypi/pyversions/wavinfo.svg) [![](https://img.shields.io/pypi/v/wavinfo.svg)](https://pypi.org/project/wavinfo/) ![](https://img.shields.io/pypi/wheel/wavinfo.svg)
@@ -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
[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
View File

@@ -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
```

View File

@@ -25,86 +25,17 @@
"metadata": {},
"outputs": [],
"source": [
"testfile_path = \"../tests/test_files/\"\n",
"sound_devices_file = testfile_path + \"A101_1.WAV\"\n",
"path = '../tests/test_files/protools/PT A101_4.A1.wav'\n",
"\n",
"info = wavinfo.WavInfoReader(sound_devices_file)"
"info = wavinfo.WavInfoReader(path)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"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": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
@@ -123,7 +54,7 @@
"source": [
"import wavinfo.wave_parser\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",
"\n",
"pp.pprint(chunk_tree.children)"
@@ -131,73 +62,68 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"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": [
"ptinfo = wavinfo.WavInfoReader(pro_tools_file)\n",
"\n",
"print(ptinfo.bext)"
"with open(path,'rb') as f:\n",
" f.seek( chunk_tree.children[4].start )\n",
" 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",
"execution_count": 10,
"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,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ ChunkDescriptor(ident=b'fmt ', start=20, length=40),\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",
" 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",
" 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"
"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"
]
}
],
"source": [
"print(info.bext)"
]
},
{
"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": [
"with open(library_sound,'rb') as f:\n",
" chunk_tree = wavinfo.wave_parser.parse_chunk(f)\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
View File

@@ -0,0 +1,2 @@
#!/bin/bash
python3 -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

View File

@@ -4,15 +4,18 @@ with open("README.md", "r") as fh:
long_description = fh.read()
setup(name='wavinfo',
version='0.1',
version='0.2',
author='Jamie Hardt',
author_email='jamiehardt@me.com',
description='WAVE sound file metadata parser.',
long_description_content_type="text/markdown",
long_description=long_description,
url='https://github.com/iluvcapra/wavinfo',
classifiers=['Development Status :: 2 - Pre-Alpha',
classifiers=['Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',
'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'])

View File

@@ -1 +1 @@
SOUND REPORT
SOUND REPORT
Can't render this file because it contains an unexpected character in line 1 and column 53.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,7 @@
import os.path
import json
import subprocess
from subprocess import PIPE
from unittest import TestCase
@@ -13,7 +14,7 @@ def ffprobe(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:
return json.loads(process.stdout)
@@ -28,7 +29,7 @@ class TestWaveInfo(TestCase):
for dirpath, dirnames, filenames in os.walk('tests/test_files'):
for filename in filenames:
name, ext = os.path.splitext(filename)
if ext == '.wav':
if ext in ['.wav','.WAV']:
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.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
#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.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):
expected = {'A101_4.WAV': {'project' : 'BMH', 'scene': 'A101', 'take': '4',

View File

@@ -87,7 +87,7 @@ class WavInfoReader():
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)
@@ -117,20 +117,49 @@ class WavInfoReader():
rest_starts = struct.calcsize(packstring)
unpacked = struct.unpack(packstring, bext_data[:rest_starts])
return WavBextFormat(description=unpacked[0].decode('ascii').rstrip('\0'),
originator = unpacked[1].decode('ascii').rstrip('\0'),
originator_ref = unpacked[2].decode('ascii').rstrip('\0'),
originator_date = unpacked[3].decode('ascii'),
originator_time = unpacked[4].decode('ascii'),
def sanatize_bytes(bytes):
first_null = next( (index for index, byte in enumerate(bytes) if byte == 0 ), None )
if first_null is not None:
trimmed = bytes[:first_null]
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],
version = unpacked[6],
umid = unpacked[7],
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,
coding_history = bext_data[rest_starts:].decode('ascii').rstrip('\0')
umid = umid,
loudness_value = loudness_value,
loudness_range = loudness_range,
max_true_peak = max_true_peak,
max_momentary_loudness = max_momentary_loudness,
max_shortterm_loudness = max_shortterm_loudness,
coding_history = sanatize_bytes(bext_data[rest_starts:])
)
def _get_ixml(self,f):