mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c46d81302 | ||
|
|
aa4aaee396 | ||
|
|
a78f5121a5 | ||
|
|
ea6f1d9d49 | ||
|
|
037a1f8333 | ||
|
|
f268feff40 | ||
|
|
8772d3eb78 | ||
|
|
71936e9441 | ||
|
|
2f8f5d962b | ||
|
|
071ca79d5e | ||
|
|
f7681d077b | ||
|
|
fa99b9d321 | ||
|
|
75395b5922 | ||
|
|
9be4487e21 | ||
|
|
3ff62fb345 | ||
|
|
4c5754a1b8 | ||
|
|
03bf50d496 | ||
|
|
2a410cef00 | ||
|
|
514160df87 | ||
|
|
3b0e754e7f | ||
|
|
62e1548031 | ||
|
|
79cd1109b3 | ||
|
|
a5f7d574bd | ||
|
|
d7cafd4d5d | ||
|
|
ec85811aaa | ||
|
|
ea60cb21b3 | ||
|
|
16d3c47373 | ||
|
|
4c9e388030 | ||
|
|
391a97d39a | ||
|
|
cf39d19ef2 |
2
.github/workflows/python-package.yml
vendored
2
.github/workflows/python-package.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install flake8 pytest
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
python -m pip install -e .
|
||||
- name: Setup FFmpeg
|
||||
uses: FedericoCarboni/setup-ffmpeg@v2
|
||||
- name: Lint with flake8
|
||||
|
||||
@@ -25,5 +25,8 @@ formats:
|
||||
|
||||
#Optionally declare the Python requirements required to build your docs
|
||||
python:
|
||||
install:
|
||||
- requirements: requirements.txt
|
||||
install:
|
||||
- method: pip
|
||||
path: .
|
||||
extra_requirements:
|
||||
- docs
|
||||
|
||||
128
CODE_OF_CONDUCT.md
Normal file
128
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
[the GitHub Issues Tab](https://github.com/iluvcapra/wavinfo/issues).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
25
README.md
25
README.md
@@ -10,13 +10,13 @@ The `wavinfo` package allows you to probe WAVE and [RF64/WAVE files][eburf64] an
|
||||
|
||||
`wavinfo` reads:
|
||||
|
||||
* [__Broadcast-WAVE__][ebu] metadata, including embedded program
|
||||
loudness, coding history and [__SMPTE UMID__][smpte_330m2011].
|
||||
* [__ADM__][adm] track metadata and schema, including channel, pack formats, object, content and programme.
|
||||
* [__Dolby Digital Plus__][ebu3285s6] and Dolby Atmos `dbmd` metadata.
|
||||
* [__iXML__][ixml] production recorder metadata, including project, scene, and take tags, recorder notes
|
||||
* [Broadcast-WAVE][bext] metadata, including embedded program
|
||||
loudness, coding history and [SMPTE UMID][smpte_330m2011].
|
||||
* [ADM][adm] track metadata and schema, including channel, pack formats, object, content and programme.
|
||||
* [Dolby Digital Plus][ebu3285s6] and Dolby Atmos `dbmd` metadata.
|
||||
* [iXML][ixml] production recorder metadata, including project, scene, and take tags, recorder notes
|
||||
and file family information.
|
||||
* Most of the common [__RIFF INFO__][info-tags] metadata fields.
|
||||
* Most of the common [RIFF INFO][info-tags] metadata fields.
|
||||
* The __wav format__ is also parsed, so you can access the basic sample rate and channel count
|
||||
information.
|
||||
|
||||
@@ -24,13 +24,14 @@ In progress:
|
||||
* Pro Tools __embedded regions__.
|
||||
* iXML `STEINBERG` sound library attributes.
|
||||
|
||||
[ebu]:https://tech.ebu.ch/docs/tech/tech3285.pdf
|
||||
[ebu3285s6]:https://tech.ebu.ch/docs/tech/tech3285s6.pdf
|
||||
[adm]:https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.2076-2-201910-I!!PDF-E.pdf
|
||||
[smpte_330m2011]:http://standards.smpte.org/content/978-1-61482-678-1/st-330-2011/SEC1.abstract
|
||||
[ixml]:http://www.ixml.info
|
||||
[bext]:https://wavinfo.readthedocs.io/en/latest/scopes/bext.html
|
||||
[smpte_330m2011]:https://wavinfo.readthedocs.io/en/latest/scopes/bext.html#wavinfo.wave_bext_reader.WavBextReader.umid
|
||||
[adm]:https://wavinfo.readthedocs.io/en/latest/scopes/adm.html
|
||||
[ebu3285s6]:https://wavinfo.readthedocs.io/en/latest/scopes/dolby.html
|
||||
[ixml]:https://wavinfo.readthedocs.io/en/latest/scopes/ixml.html
|
||||
[info-tags]:https://wavinfo.readthedocs.io/en/latest/scopes/info.html
|
||||
[eburf64]:https://tech.ebu.ch/docs/tech/tech3306v1_1.pdf
|
||||
[info-tags]:https://exiftool.org/TagNames/RIFF.html#Info
|
||||
|
||||
|
||||
## How To Use
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ copyright = u'2022, Jamie Hardt'
|
||||
author = u'Jamie Hardt'
|
||||
|
||||
# The short X.Y version
|
||||
version = wavinfo.__version__
|
||||
version = wavinfo.__short_version__
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = wavinfo.__version__
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ music production metadata.
|
||||
quickstart
|
||||
command_line
|
||||
scopes/*
|
||||
|
||||
classes
|
||||
references
|
||||
|
||||
|
||||
Indices and tables
|
||||
|
||||
@@ -14,7 +14,10 @@ instance of :class:`WaveInfoReader`.
|
||||
path = 'path/to/your/wave/audio.wav'
|
||||
|
||||
info = wavinfo.WavInfoReader(path)
|
||||
|
||||
|
||||
adm_metadata = info.adm
|
||||
ixml_metadata = info.ixml
|
||||
|
||||
|
||||
.. module:: wavinfo
|
||||
:noindex:
|
||||
|
||||
39
docs/source/references.rst
Normal file
39
docs/source/references.rst
Normal file
@@ -0,0 +1,39 @@
|
||||
References
|
||||
==========
|
||||
|
||||
Wave File Format
|
||||
----------------
|
||||
|
||||
* `ITU Recommendation BS.2088-1-2019 — Long-form file format for the international exchange of audio programme materials with metadata <https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.2088-1-201910-I!!PDF-E.pdf>`_
|
||||
* `IETF Network Working Group RFC2361 — WAVE and AVI Codec Registries <https://www.rfc-editor.org/rfc/rfc2361>`_
|
||||
|
||||
Broadcast Wave Format
|
||||
---------------------
|
||||
|
||||
* `EBU Tech 3285 — Specification of the Broadcast Wave Format (BWF) <https://tech.ebu.ch/docs/tech/tech3285.pdf>`_
|
||||
* `EBU Tech 3306 — MBWF / RF64: An extended File Format for Audio <https://tech.ebu.ch/docs/tech/tech3306v1_1.pdf>`_
|
||||
* `SMPTE ST 330-2011 — Unique Material Identifier <https://ieeexplore.ieee.org/document/9787389>`_
|
||||
|
||||
Audio Definition Model
|
||||
----------------------
|
||||
|
||||
* `ITU Recommendation BS.2076-2-2019 — Audio definition model <https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.2076-2-201910-I!!PDF-E.pdf>`_
|
||||
* `EBU Tech 3285 Supplement 5 — <axml> Chunk <https://tech.ebu.ch/docs/tech/tech3285s5.pdf>`_
|
||||
* `EBU ADM Guidelines <https://adm.ebu.io>`_
|
||||
|
||||
Dolby
|
||||
-----
|
||||
|
||||
* `EBU Tech 3285 Supplement 6 — Dolby Metadata <https://tech.ebu.ch/docs/tech/tech3285s6.pdf>`_
|
||||
* `Dolby Laboratories Atmos ADM Profile <https://developer.dolby.com/globalassets/documentation/technology/dolby_atmos_master_adm_profile_v1.0.pdf>`_
|
||||
|
||||
iXML
|
||||
----
|
||||
|
||||
* `Gallery Software iXML Specification <http://www.gallery.co.uk/ixml/>`_
|
||||
|
||||
|
||||
RIFF INFO
|
||||
---------
|
||||
* `Exiftool Documentation <https://exiftool.org/TagNames/RIFF.html#Info_docs>`_
|
||||
|
||||
@@ -40,4 +40,9 @@ Class Reference
|
||||
.. autoclass:: wavinfo.wave_ixml_reader.WavIXMLFormat
|
||||
:members:
|
||||
|
||||
Steinberg-Specific iXML Metadata
|
||||
--------------------------------
|
||||
|
||||
.. autoclass:: wavinfo.wave_ixml_reader.SteinbergMetadata
|
||||
:members:
|
||||
|
||||
|
||||
70
pyproject.toml
Normal file
70
pyproject.toml
Normal file
@@ -0,0 +1,70 @@
|
||||
[build-system]
|
||||
requires = ["flit_core >=3.2,<4"]
|
||||
build-backend = "flit_core.buildapi"
|
||||
|
||||
[project]
|
||||
name = "wavinfo"
|
||||
authors = [{name = "Jamie Hardt", email = "jamiehardt@me.com"}]
|
||||
readme = "README.md"
|
||||
dynamic = ["version", "description"]
|
||||
requires-python = "~=3.8"
|
||||
classifiers = [
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Topic :: Multimedia',
|
||||
'Topic :: Multimedia :: Sound/Audio',
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11"
|
||||
]
|
||||
dependencies = [
|
||||
"lxml ~= 4.9.2"
|
||||
]
|
||||
keywords = [
|
||||
'waveform',
|
||||
'metadata',
|
||||
'audio',
|
||||
'ebu',
|
||||
'smpte',
|
||||
'avi',
|
||||
'library',
|
||||
'film',
|
||||
'broadcast'
|
||||
]
|
||||
|
||||
[tool.flit.module]
|
||||
name = "wavinfo"
|
||||
|
||||
[project.optional-dependencies]
|
||||
doc = [
|
||||
'sphinx >= 5.3.0',
|
||||
'sphinx_rtd_theme >= 1.1.1',
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Home = "https://github.com/iluvcapra/wavinfo"
|
||||
Documentation = "https://wavinfo.readthedocs.io/"
|
||||
Source = "https://github.com/iluvcapra/wavinfo.git"
|
||||
Issues = 'https://github.com/iluvcapra/wavinfo/issues'
|
||||
|
||||
[project.entry_points.console_scripts]
|
||||
wavinfo = 'wavinfo.__main__:main'
|
||||
|
||||
[project.scripts]
|
||||
wavinfo = "wavinfo.__main__:main"
|
||||
|
||||
[tool.pyright]
|
||||
typeCheckingMode = "basic"
|
||||
|
||||
[tool.pylint]
|
||||
max-line-length = 88
|
||||
disable = [
|
||||
"C0103", # (invalid-name)
|
||||
"C0114", # (missing-module-docstring)
|
||||
"C0115", # (missing-class-docstring)
|
||||
"C0116", # (missing-function-docstring)
|
||||
"R0903", # (too-few-public-methods)
|
||||
"R0913", # (too-many-arguments)
|
||||
"W0105", # (pointless-string-statement)
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
lxml==4.9.1
|
||||
40
setup.py
40
setup.py
@@ -1,40 +0,0 @@
|
||||
from setuptools import setup
|
||||
from wavinfo import __author__, __license__, __version__
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setup(name='wavinfo',
|
||||
version=__version__,
|
||||
author=__author__,
|
||||
author_email='jamiehardt@me.com',
|
||||
description='Probe WAVE Files for iXML, Broadcast-WAVE and other metadata.',
|
||||
long_description_content_type="text/markdown",
|
||||
long_description=long_description,
|
||||
license=__license__,
|
||||
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',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Topic :: Multimedia',
|
||||
'Topic :: Multimedia :: Sound/Audio',
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11"],
|
||||
keywords='waveform metadata audio ebu smpte avi library film tv editing editorial',
|
||||
install_requires=['lxml'],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'wavinfo = wavinfo.__main__:main'
|
||||
]
|
||||
}
|
||||
)
|
||||
@@ -1,3 +1,44 @@
|
||||
from . import test_wave_parsing
|
||||
|
||||
from io import BytesIO
|
||||
from typing import Generator
|
||||
import zipfile as zf
|
||||
import os.path
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
|
||||
# class TestFileLoader:
|
||||
# """
|
||||
# This guy manages the test_files archive.
|
||||
# """
|
||||
|
||||
# def __init__(self, test_file_arch_name = 'archive.zip') -> None:
|
||||
# self.base_path = os.path.join(os.path.dirname(__file__), "test_files")
|
||||
# self.test_file_arch_name = test_file_arch_name
|
||||
# self._gather_test_files_into_archive()
|
||||
|
||||
# @property
|
||||
# def arch_path(self):
|
||||
# return os.path.join(self.base_path, self.test_file_arch_name)
|
||||
|
||||
# @contextmanager
|
||||
# def open(self, name) -> Generator[BytesIO]:
|
||||
# z = zf.ZipFile(self.arch_path, 'r')
|
||||
# member = z.open(name, 'r')
|
||||
# try:
|
||||
# yield member
|
||||
# finally:
|
||||
# zf.close()
|
||||
|
||||
# def _gather_test_files_into_archive(self):
|
||||
# with zf.ZipFile(self.arch_path, 'a') as zip:
|
||||
# for root, _, files in os.walk(self.base_path):
|
||||
# for name in files:
|
||||
# if root == self.base_path and name == self.test_file_arch_name:
|
||||
# continue
|
||||
# else:
|
||||
# p = os.path.join(root, name)
|
||||
# zip.write(p)
|
||||
# os.unlink(p)
|
||||
|
||||
|
||||
|
||||
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 1OA.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 1OA.wav
Normal file
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 2OA.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 2OA.wav
Normal file
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 3OA.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 3OA.wav
Normal file
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 5.0.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 5.0.wav
Normal file
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 5.1.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 5.1.wav
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 7.0.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 7.0.wav
Normal file
Binary file not shown.
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 7.1.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - 7.1.wav
Normal file
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - LRC.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - LRC.wav
Normal file
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - LRCS.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - LRCS.wav
Normal file
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - Mono.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - Mono.wav
Normal file
Binary file not shown.
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - Quad.wav
Normal file
BIN
tests/test_files/nuendo/wavinfo Test Project - Audio - Quad.wav
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,12 +1,9 @@
|
||||
"""
|
||||
methods to probe a WAV file for various kinds of production metadata.
|
||||
|
||||
See the documentation for `wavinfo.WavInfoReader` for more information.
|
||||
Probe WAVE Files for iXML, Broadcast-WAVE and other metadata.
|
||||
"""
|
||||
|
||||
from .wave_reader import WavInfoReader
|
||||
from .riff_parser import WavInfoEOFError
|
||||
|
||||
__version__ = '2.1.0'
|
||||
__author__ = 'Jamie Hardt <jamiehardt@gmail.com>'
|
||||
__license__ = "MIT"
|
||||
__version__ = '2.2.0'
|
||||
__short_version__ = '2.2.0'
|
||||
|
||||
@@ -19,7 +19,7 @@ class MissingDataError(RuntimeError):
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
|
||||
parser.usage = 'wavinfo (--adm | --ixml) [FILES]'
|
||||
parser.usage = 'wavinfo (--adm | --ixml) <FILE> +'
|
||||
|
||||
# parser.add_option('-f', dest='output_format', help='Set the output format',
|
||||
# default='json',
|
||||
@@ -42,7 +42,7 @@ def main():
|
||||
raise MissingDataError("adm")
|
||||
elif options.ixml:
|
||||
if this_file.ixml:
|
||||
sys.stdout.write(this_file.ixml.xml_bytes())
|
||||
sys.stdout.write(this_file.ixml.xml_str())
|
||||
else:
|
||||
raise MissingDataError("ixml")
|
||||
else:
|
||||
|
||||
@@ -53,7 +53,7 @@ class WavADMReader:
|
||||
|
||||
def programme(self) -> dict:
|
||||
"""
|
||||
Extract the ADM audioProgramme data structure and some of its reference properties
|
||||
Read the ADM `audioProgramme` data structure and some of its reference properties.
|
||||
"""
|
||||
ret_dict = dict()
|
||||
|
||||
@@ -95,7 +95,7 @@ class WavADMReader:
|
||||
|
||||
return ret_dict
|
||||
|
||||
def track_info(self, index):
|
||||
def track_info(self, index) -> dict:
|
||||
"""
|
||||
Information about a track in the WAV file.
|
||||
|
||||
@@ -151,7 +151,7 @@ class WavADMReader:
|
||||
|
||||
return ret_dict
|
||||
|
||||
def to_dict(self):
|
||||
def to_dict(self) -> dict: #FIXME should be "asdict"
|
||||
"""
|
||||
Get ADM metadata as a dictionary.
|
||||
"""
|
||||
|
||||
@@ -25,34 +25,47 @@ class WavBextReader:
|
||||
|
||||
#: Description. A free-text field up to 256 characters long.
|
||||
self.description : str = sanitize_bytes(unpacked[0])
|
||||
|
||||
#: Originator. Usually the name of the encoding application, sometimes
|
||||
#: a artist name.
|
||||
#: an artist name.
|
||||
self.originator : str = sanitize_bytes(unpacked[1])
|
||||
|
||||
#: A unique identifier for the file, a serial number.
|
||||
self.originator_ref : str = sanitize_bytes(unpacked[2])
|
||||
#: Date of the recording, in the format YYYY-MM-DD in the local calendar
|
||||
|
||||
#: Date of the recording, in the format YYYY-MM-DD.
|
||||
self.originator_date : str = sanitize_bytes(unpacked[3])
|
||||
#: Time of the recording, in the format HH:MM:SS on the local clock
|
||||
|
||||
#: Time of the recording, in the format HH:MM:SS.
|
||||
self.originator_time : str = sanitize_bytes(unpacked[4])
|
||||
#: The sample offset of the start of the file relative to an
|
||||
#: epoch, usually midnight the day of the recording.
|
||||
|
||||
#: The sample offset of the start, usually relative
|
||||
#: to midnight.
|
||||
self.time_reference : int = unpacked[5]
|
||||
|
||||
#: A variable-length text field containing a list of processes and
|
||||
#: and conversions performed on the file.
|
||||
self.coding_history : str = sanitize_bytes(bext_data[rest_starts:])
|
||||
|
||||
#: BEXT version.
|
||||
self.version : int = unpacked[6]
|
||||
|
||||
#: SMPTE 330M UMID of this audio file, 64 bytes are allocated though the UMID
|
||||
#: may only be 32 bytes long.
|
||||
self.umid : Optional[bytes] = None
|
||||
|
||||
#: EBU R128 Integrated loudness, in LUFS.
|
||||
self.loudness_value : Optional[float] = None
|
||||
#: EBU R128 Loudness rante, in LUFS.
|
||||
|
||||
#: EBU R128 Loudness range, in LUFS.
|
||||
self.loudness_range : Optional[float] = None
|
||||
|
||||
#: True peak level, in dBFS TP
|
||||
self.max_true_peak : Optional[float] = None
|
||||
|
||||
#: EBU R128 Maximum momentary loudness, in LUFS
|
||||
self.max_momentary_loudness : Optional[float] = None
|
||||
|
||||
#: EBU R128 Maximum short-term loudness, in LUFS.
|
||||
self.max_shortterm_loudness : Optional[float] = None
|
||||
|
||||
|
||||
@@ -598,7 +598,7 @@ class WavDolbyMetadataReader:
|
||||
return retval
|
||||
|
||||
|
||||
def __init__(self, dbmd_data) -> None:
|
||||
def __init__(self, dbmd_data):
|
||||
self.segment_list = []
|
||||
|
||||
h = BytesIO(dbmd_data)
|
||||
|
||||
@@ -21,7 +21,7 @@ class WavInfoChunkReader:
|
||||
self.album : Optional[str] = self.product
|
||||
#: 'IGNR' Genre
|
||||
self.genre : Optional[str] = self._get_field(f, b'IGNR')
|
||||
#: 'ISBJ' Supject
|
||||
#: 'ISBJ' Subject
|
||||
self.subject : Optional[str] = self._get_field(f, b'ISBJ')
|
||||
#: 'IART' Artist, composer, author
|
||||
self.artist : Optional[str] = self._get_field(f, b'IART')
|
||||
@@ -59,7 +59,7 @@ class WavInfoChunkReader:
|
||||
else:
|
||||
return None
|
||||
|
||||
def to_dict(self):
|
||||
def to_dict(self) -> dict: #FIXME should be asdict
|
||||
"""
|
||||
A dictionary with all of the key/values read from the INFO scope.
|
||||
"""
|
||||
|
||||
@@ -2,10 +2,139 @@ from lxml import etree as ET
|
||||
import io
|
||||
from collections import namedtuple
|
||||
from typing import Optional
|
||||
from enum import IntEnum
|
||||
|
||||
IXMLTrack = namedtuple('IXMLTrack', ['channel_index', 'interleave_index', 'name', 'function'])
|
||||
|
||||
|
||||
class SteinbergMetadata:
|
||||
"""
|
||||
Vendor-specific Steinberg metadata.
|
||||
"""
|
||||
|
||||
class AudioSpeakerArrangement(IntEnum):
|
||||
"""
|
||||
Steinberg speaker format enumeration.
|
||||
"""
|
||||
MONO = 0
|
||||
STEREO = 1
|
||||
LRC = 10
|
||||
LRCS = 14
|
||||
QUAD = 15
|
||||
CINE_50 = 18
|
||||
CINE_51 = 19
|
||||
CINE_60 = 20
|
||||
CINE_61 = 22
|
||||
CINE_70 = 25
|
||||
CINE_71 = 27
|
||||
SDDS_70 = 24
|
||||
SDDS_71 = 26
|
||||
MUSIC_60 = 21 #??
|
||||
MUSIC_61 = 23
|
||||
ATMOS_712 = 33
|
||||
ATMOS_504 = 35
|
||||
ATMOS_514 = 36
|
||||
ATMOS_714 = 44
|
||||
ATMOS_702 = 48
|
||||
ATMOS_716 = 51
|
||||
ATMOS_914 = 53
|
||||
ATMOS_916 = 55
|
||||
AMB_1ORDER = 45
|
||||
AMB_2ORDER = 46
|
||||
AMB_3ORDER = 47
|
||||
AURO_10_0 = 37
|
||||
AURO_10_1 = 38
|
||||
AURO_11_0 = 39
|
||||
AURO_11_1 = 40
|
||||
AURO_13_0 = 41
|
||||
AURO_13_1 = 42
|
||||
|
||||
Steinberg_xpath = "//BWFXML/STEINBERG"
|
||||
|
||||
@classmethod
|
||||
def present(cls, xml: ET.ElementTree) -> bool:
|
||||
"""
|
||||
Test if `xml` has Steinberg metadata.
|
||||
:param xml: an iXML ElementTree
|
||||
"""
|
||||
x = xml.find(cls.Steinberg_xpath)
|
||||
return len(x) > 0
|
||||
|
||||
def __init__(self, xml: ET.ElementTree) -> None:
|
||||
"""
|
||||
Parse Steinberg iXML data.
|
||||
:param xml: The entire iXML Tree
|
||||
"""
|
||||
self.parsed = xml.find("//BWFXML/STEINBERG")
|
||||
|
||||
@property
|
||||
def audio_speaker_arrangement(self) -> Optional[AudioSpeakerArrangement]:
|
||||
"""
|
||||
`AudioSpeakerArrangement` property
|
||||
"""
|
||||
val = self.parsed.find("./ATTR_LIST/ATTR[NAME/text() = 'AudioSpeakerArrangement']/VALUE/text()")
|
||||
if len(val) > 0:
|
||||
return type(self).AudioSpeakerArrangement(int(val[0]))
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def sample_format_size(self) -> Optional[int]:
|
||||
"""
|
||||
AudioSampleFormatSize
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def media_company(self) -> Optional[str]:
|
||||
"""
|
||||
MediaCompany
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def media_drop_frames(self) -> Optional[bool]:
|
||||
"""
|
||||
MediaDropFrames
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def media_duration(self) -> Optional[float]:
|
||||
"""
|
||||
MediaDuration
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def media_start_time(self) -> Optional[float]:
|
||||
"""
|
||||
MediaStartTime
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def media_track_title(self) -> Optional[str]:
|
||||
"""
|
||||
MediaTrackTitle
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def program_name(self) -> Optional[str]:
|
||||
"""
|
||||
ProgramName
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def program_version(self) -> Optional[str]:
|
||||
"""
|
||||
ProgramVersion
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class WavIXMLFormat:
|
||||
"""
|
||||
iXML recorder metadata.
|
||||
@@ -18,7 +147,7 @@ class WavIXMLFormat:
|
||||
self.source = xml
|
||||
xml_bytes = io.BytesIO(xml)
|
||||
parser = ET.XMLParser(recover=True)
|
||||
self.parsed = ET.parse(xml_bytes, parser=parser)
|
||||
self.parsed : ET.ElementTree = ET.parse(xml_bytes, parser=parser)
|
||||
|
||||
def _get_text_value(self, xpath) -> Optional[str]:
|
||||
e = self.parsed.find("./" + xpath)
|
||||
@@ -27,11 +156,11 @@ class WavIXMLFormat:
|
||||
else:
|
||||
return None
|
||||
|
||||
def xml_bytes(self):
|
||||
def xml_str(self) -> str:
|
||||
return ET.tostring(self.parsed).decode("utf-8")
|
||||
|
||||
@property
|
||||
def raw_xml(self):
|
||||
def raw_xml(self) -> ET.ElementTree:
|
||||
"""
|
||||
The root entity of the iXML document.
|
||||
"""
|
||||
@@ -41,7 +170,8 @@ class WavIXMLFormat:
|
||||
def track_list(self):
|
||||
"""
|
||||
A description of each track.
|
||||
:returns: An Iterator
|
||||
|
||||
:yields: `IXMLTrack` for each track.
|
||||
"""
|
||||
for track in self.parsed.find("./TRACK_LIST").iter():
|
||||
if track.tag == 'TRACK':
|
||||
@@ -93,6 +223,16 @@ class WavIXMLFormat:
|
||||
"""
|
||||
return self._get_text_value("FILE_SET/FAMILY_NAME")
|
||||
|
||||
@property
|
||||
def steinberg(self) -> Optional[SteinbergMetadata]:
|
||||
"""
|
||||
Steinberg vendor iXML metadata if present.
|
||||
"""
|
||||
if SteinbergMetadata.present(self.raw_xml):
|
||||
return SteinbergMetadata(self.raw_xml)
|
||||
else:
|
||||
return None
|
||||
|
||||
def to_dict(self):
|
||||
return dict(track_list=list(map(lambda x: x._asdict(), self.track_list)),
|
||||
project=self.project,
|
||||
|
||||
@@ -34,7 +34,7 @@ class WavInfoReader:
|
||||
Create a new reader object.
|
||||
|
||||
:param path:
|
||||
A filesystem path to the wav file you wish to probe or a
|
||||
A pathlike object or IO to the wav file you wish to probe or a
|
||||
file handle to an open file.
|
||||
|
||||
:param info_encoding:
|
||||
@@ -45,17 +45,37 @@ class WavInfoReader:
|
||||
The text encoding to use when decoding the string
|
||||
fields of the Broadcast-WAV extension. Per EBU 3285 this is ASCII
|
||||
but this parameter is available to you if you encounter a weirdo.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
self.info_encoding = info_encoding
|
||||
self.bext_encoding = bext_encoding
|
||||
|
||||
#: Wave audio data format.
|
||||
self.fmt :Optional[WavAudioFormat] = None
|
||||
|
||||
#: Statistics of the `data` section.
|
||||
self.data :Optional[WavDataDescriptor] = None
|
||||
|
||||
#: Broadcast-Wave metadata.
|
||||
self.bext :Optional[WavBextReader] = None
|
||||
|
||||
#: iXML metadata.
|
||||
self.ixml :Optional[WavIXMLFormat] = None
|
||||
|
||||
#: ADM Audio Definiton Model metadata.
|
||||
self.adm :Optional[WavADMReader]= None
|
||||
|
||||
#: Dolby bitstream metadata.
|
||||
self.dolby :Optional[WavDolbyMetadataReader] = None
|
||||
|
||||
#: RIFF INFO metadata.
|
||||
self.info :Optional[WavInfoChunkReader]= None
|
||||
|
||||
if hasattr(path, 'read'):
|
||||
self.get_wav_info(path)
|
||||
self.url = 'about:blank'
|
||||
self.path = repr(path)
|
||||
|
||||
else:
|
||||
absolute_path = os.path.abspath(path)
|
||||
|
||||
@@ -63,28 +83,7 @@ class WavInfoReader:
|
||||
self.url: pathlib.Path = pathlib.Path(absolute_path).as_uri()
|
||||
|
||||
self.path = absolute_path
|
||||
|
||||
#: Wave audio data format.
|
||||
self.fmt :Optional[WavAudioFormat] = None
|
||||
|
||||
#: Statistics of the `data` section.
|
||||
self.data :Optional[WavDataDescriptor] = None
|
||||
|
||||
#: Broadcast-Wave metadata.
|
||||
self.bext :Optional[WavBextReader] = None
|
||||
|
||||
#: iXML metadata.
|
||||
self.ixml :Optional[WavIXMLFormat] = None
|
||||
|
||||
#: ADM Audio Definiton Model metadata.
|
||||
self.adm :Optional[WavADMReader]= None
|
||||
|
||||
#: Dolby bitstream metadata.
|
||||
self.dolby :Optional[WavDolbyMetadataReader] = None
|
||||
|
||||
#: RIFF INFO metadata.
|
||||
self.info :Optional[WavInfoChunkReader]= None
|
||||
|
||||
|
||||
with open(path, 'rb') as f:
|
||||
self.get_wav_info(f)
|
||||
|
||||
|
||||
34
wavinfo/wavfind.py
Normal file
34
wavinfo/wavfind.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
from optparse import OptionParser, OptionGroup
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
|
||||
parser.usage = "wavfind [--scene=SCENE] [--take=TAKE] [--desc=DESC] <PATH> +"
|
||||
|
||||
primaries = OptionGroup(parser, title="Search Predicates",
|
||||
description="Argument values can be globs, and are logically-AND'ed.")
|
||||
|
||||
primaries.add_option("--scene",
|
||||
help='Search for this scene',
|
||||
metavar='SCENE')
|
||||
|
||||
primaries.add_option("--take",
|
||||
help='Search for this take',
|
||||
metavar='TAKE')
|
||||
|
||||
primaries.add_option("--desc",
|
||||
help='Search descriptions',
|
||||
metavar='DESC')
|
||||
|
||||
|
||||
(options, args) = parser.parse_args(sys.argv)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user