mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-01 01:10:40 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
841b86f3f4 | ||
|
|
5c90d5ff47 | ||
|
|
60e329fdb4 | ||
|
|
15db4c9ffa | ||
|
|
49ac961b94 | ||
|
|
7fc530b2cd |
@@ -5,6 +5,7 @@ python:
|
|||||||
- "3.6"
|
- "3.6"
|
||||||
- "3.5"
|
- "3.5"
|
||||||
- "3.7"
|
- "3.7"
|
||||||
|
- "3.8"
|
||||||
script:
|
script:
|
||||||
- "gunzip tests/test_files/rf64/*.gz"
|
- "gunzip tests/test_files/rf64/*.gz"
|
||||||
- "python setup.py test"
|
- "python setup.py test"
|
||||||
|
|||||||
18
setup.py
18
setup.py
@@ -4,20 +4,30 @@ with open("README.md", "r") as fh:
|
|||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
|
|
||||||
setup(name='wavinfo',
|
setup(name='wavinfo',
|
||||||
version='1.3',
|
version='1.4',
|
||||||
author='Jamie Hardt',
|
author='Jamie Hardt',
|
||||||
author_email='jamiehardt@me.com',
|
author_email='jamiehardt@me.com',
|
||||||
description='Probe WAVE Files for iXML, Broadcast-WAVE and other metadata.',
|
description='Probe WAVE Files for iXML, Broadcast-WAVE and other metadata.',
|
||||||
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',
|
||||||
|
project_urls={
|
||||||
|
'Source':
|
||||||
|
'https://github.com/iluvcapra/wavinfo',
|
||||||
|
'Documentation':
|
||||||
|
'https://wavinfo.readthedocs.io/',
|
||||||
|
'Issues':
|
||||||
|
'https://github.com/iluvcapra/wavinfo/issues',
|
||||||
|
},
|
||||||
|
packages=['wavinfo'],
|
||||||
classifiers=['Development Status :: 5 - Production/Stable',
|
classifiers=['Development Status :: 5 - Production/Stable',
|
||||||
'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.5",
|
"Programming Language :: Python :: 3.5",
|
||||||
"Programming Language :: Python :: 3.6",
|
"Programming Language :: Python :: 3.6",
|
||||||
"Programming Language :: Python :: 3.7"],
|
"Programming Language :: Python :: 3.7",
|
||||||
packages=['wavinfo'],
|
"Programming Language :: Python :: 3.8"],
|
||||||
|
keywords='waveform metadata audio ebu smpte avi library film tv editing editorial',
|
||||||
install_requires=['lxml']
|
install_requires=['lxml']
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
"""
|
||||||
|
methods to probe a WAV file for various kinds of production metadata.
|
||||||
# :module:`wavinfo` provides methods to probe a WAV file for
|
|
||||||
# various kinds of production metadata.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
|
Go to the documentation for wavinfo.WavInfoReader for more information.
|
||||||
|
"""
|
||||||
|
|
||||||
from .wave_reader import WavInfoReader
|
from .wave_reader import WavInfoReader
|
||||||
|
from .riff_parser import WavInfoEOFError
|
||||||
|
|
||||||
__version__ = '1.3'
|
__version__ = '1.4'
|
||||||
__author__ = 'Jamie Hardt'
|
__author__ = 'Jamie Hardt <jamiehardt@gmail.com>'
|
||||||
|
__license__ = "MIT"
|
||||||
@@ -1,70 +1,72 @@
|
|||||||
|
|
||||||
import struct
|
import struct
|
||||||
import pdb
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from .rf64_parser import parse_rf64
|
from .rf64_parser import parse_rf64
|
||||||
|
|
||||||
class ListChunkDescriptor(namedtuple('ListChunkDescriptor' , 'signature children')):
|
|
||||||
|
|
||||||
def find(chunk_path):
|
class WavInfoEOFError(EOFError):
|
||||||
|
def __init__(self, identifier, chunk_start):
|
||||||
|
self.identifier = identifier
|
||||||
|
self.chunk_start = chunk_start
|
||||||
|
|
||||||
|
|
||||||
|
class ListChunkDescriptor(namedtuple('ListChunkDescriptor', 'signature children')):
|
||||||
|
def find(self, chunk_path):
|
||||||
if len(chunk_path) > 1:
|
if len(chunk_path) > 1:
|
||||||
for chunk in self.children:
|
for chunk in self.children:
|
||||||
if type(chunk) is ListChunkDescriptor and \
|
if type(chunk) is ListChunkDescriptor and \
|
||||||
chunk.signature is chunk_path[0]:
|
chunk.signature is chunk_path[0]:
|
||||||
return chunk.find(chunk_path[1:])
|
return chunk.find(chunk_path[1:])
|
||||||
else:
|
else:
|
||||||
for chunk in self.children:
|
for chunk in self.children:
|
||||||
if type(chunk) is ChunkDescriptor and \
|
if type(chunk) is ChunkDescriptor and \
|
||||||
chunk.ident is chunk_path[0]:
|
chunk.ident is chunk_path[0]:
|
||||||
return chunk
|
return chunk
|
||||||
|
|
||||||
|
|
||||||
class ChunkDescriptor(namedtuple('ChunkDescriptor', 'ident start length rf64_context') ):
|
class ChunkDescriptor(namedtuple('ChunkDescriptor', 'ident start length rf64_context')):
|
||||||
def read_data(self, from_stream):
|
def read_data(self, from_stream):
|
||||||
from_stream.seek(self.start)
|
from_stream.seek(self.start)
|
||||||
return from_stream.read(self.length)
|
return from_stream.read(self.length)
|
||||||
|
|
||||||
def parse_list_chunk(stream, length, rf64_context =None):
|
|
||||||
start = stream.tell()
|
|
||||||
|
|
||||||
|
def parse_list_chunk(stream, length, rf64_context=None):
|
||||||
|
start = stream.tell()
|
||||||
signature = stream.read(4)
|
signature = stream.read(4)
|
||||||
|
|
||||||
#print("Parsing list chunk with siganture: ", signature)
|
|
||||||
children = []
|
children = []
|
||||||
while (stream.tell() - start) < length:
|
while (stream.tell() - start + 8) < length:
|
||||||
child_chunk = parse_chunk(stream, rf64_context= rf64_context)
|
child_chunk = parse_chunk(stream, rf64_context=rf64_context)
|
||||||
if child_chunk:
|
children.append(child_chunk)
|
||||||
children.append(child_chunk)
|
|
||||||
else:
|
stream.seek(start + length)
|
||||||
break
|
|
||||||
|
|
||||||
return ListChunkDescriptor(signature=signature, children=children)
|
return ListChunkDescriptor(signature=signature, children=children)
|
||||||
|
|
||||||
|
|
||||||
def parse_chunk(stream, rf64_context=None):
|
def parse_chunk(stream, rf64_context=None):
|
||||||
|
header_start = stream.tell()
|
||||||
ident = stream.read(4)
|
ident = stream.read(4)
|
||||||
if len(ident) != 4:
|
size_bytes = stream.read(4)
|
||||||
return
|
|
||||||
|
|
||||||
sizeb = stream.read(4)
|
if len(ident) != 4 or len(size_bytes) != 4:
|
||||||
size = struct.unpack('<I',sizeb)[0]
|
raise WavInfoEOFError(identifier=ident, chunk_start=header_start)
|
||||||
|
|
||||||
if size == 0xFFFFFFFF:
|
data_size = struct.unpack('<I', size_bytes)[0]
|
||||||
|
|
||||||
|
if data_size == 0xFFFFFFFF:
|
||||||
if rf64_context is None and ident == b'RF64':
|
if rf64_context is None and ident == b'RF64':
|
||||||
rf64_context = parse_rf64(stream=stream)
|
rf64_context = parse_rf64(stream=stream)
|
||||||
|
|
||||||
size = rf64_context.bigchunk_table[ident]
|
data_size = rf64_context.bigchunk_table[ident]
|
||||||
|
|
||||||
displacement = size
|
displacement = data_size
|
||||||
if displacement % 2 is not 0:
|
if displacement % 2 is not 0:
|
||||||
displacement = displacement + 1
|
displacement = displacement + 1
|
||||||
|
|
||||||
if ident in [b'RIFF',b'LIST', b'RF64']:
|
if ident in [b'RIFF', b'LIST', b'RF64']:
|
||||||
#print("Parsing list chunk with ident: ", ident)
|
return parse_list_chunk(stream=stream, length=data_size, rf64_context=rf64_context)
|
||||||
return parse_list_chunk(stream=stream, length=size, rf64_context=rf64_context)
|
|
||||||
else:
|
else:
|
||||||
start = stream.tell()
|
data_start = stream.tell()
|
||||||
stream.seek(displacement,1)
|
stream.seek(displacement, 1)
|
||||||
#print("Parsing chunk with start=%i, ident=%s" % (start, ident))
|
return ChunkDescriptor(ident=ident, start=data_start, length=data_size, rf64_context=rf64_context)
|
||||||
return ChunkDescriptor(ident=ident, start=start, length=size, rf64_context=rf64_context)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user