-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
paranarimasu
committed
Oct 25, 2020
0 parents
commit 184b81c
Showing
8 changed files
with
544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/python | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=python | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
pytestdebug.log | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
doc/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
pythonenv* | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# profiling data | ||
.prof | ||
|
||
# JetBrains IDEs | ||
.idea | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 paranarimasu | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
### Description | ||
|
||
Verify WebM(s) Against AnimeThemes Encoding Standards | ||
|
||
Executes a test suite on the input WebM(s) to verify compliance. | ||
|
||
Test success/failure does **NOT** guarantee acceptance/rejection of submissions. In some tests, we are determining the correctness of our file properties. In other tests, we are flagging uncommon property values for inspection. | ||
|
||
### Install | ||
|
||
**Requirements:** | ||
|
||
* FFmpeg | ||
* Python >= 3.6 | ||
|
||
**Install:** | ||
|
||
pip install animethemes-webm-verifier | ||
|
||
### Usage | ||
|
||
python -m test_webm [-h] [--loglevel [{debug,info,error}] [file [file ...]] | ||
|
||
* `--loglevel error`: Only show error messages | ||
* `--loglevel info`: Show error messages and script progression info messages | ||
* `--loglevel debug`: Show all messages, including variable dumps | ||
* `[file ...]`: The WebM(s) to verify. If not provided, we will test all WebMs in the current directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from setuptools import setup, find_packages | ||
|
||
with open('README.md') as f: | ||
long_description = f.read() | ||
|
||
setup( | ||
name='animethemes-webm-verifier', | ||
version='1.0', | ||
author='paranarimasu', | ||
author_email='paranarimasu@gmail.com', | ||
url='https://github.com/AnimeThemes/animethemes-webm-verifier', | ||
description='Verify WebM(s) Against AnimeThemes Encoding Standards', | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
packages=find_packages(), | ||
classifiers=[ | ||
'Intended Audience :: Developers', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'License :: OSI Approved :: MIT License', | ||
'Natural Language :: English', | ||
'Operating System :: OS Independent', | ||
], | ||
python_requires='>=3.6', | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
from ._test_webm import TestWebm | ||
from ._utils import file_arg_type | ||
|
||
import argparse | ||
import logging | ||
import os | ||
import shutil | ||
import sys | ||
import unittest | ||
|
||
|
||
def main(): | ||
# Load/Validate Arguments | ||
parser = argparse.ArgumentParser(prog='test_webm', | ||
description='Verify WebM(s) Against /r/AnimeThemes Encoding Standards', | ||
formatter_class=argparse.RawTextHelpFormatter) | ||
parser.add_argument('file', | ||
nargs='*', | ||
default=[f for f in os.listdir('.') if f.endswith('.webm')], | ||
type=file_arg_type, | ||
help='The WebM(s) to verify') | ||
parser.add_argument('--loglevel', | ||
nargs='?', | ||
default='info', | ||
choices=['debug', 'info', 'error'], | ||
help='Set logging level') | ||
args = parser.parse_args() | ||
|
||
# Logging Config | ||
logging.basicConfig(stream=sys.stdout, | ||
level=logging.getLevelName(args.loglevel.upper()), | ||
format='%(levelname)s: %(message)s') | ||
|
||
# Env Check: Check that dependencies are installed | ||
if shutil.which('ffmpeg') is None: | ||
logging.error('FFmpeg is required') | ||
sys.exit() | ||
|
||
if shutil.which('ffprobe') is None: | ||
logging.error('FFprobe is required') | ||
sys.exit() | ||
|
||
if not args.file: | ||
logging.error('No WebMs to verify') | ||
sys.exit() | ||
|
||
logging.info('Verifying files...') | ||
|
||
for file in args.file: | ||
logging.info(f'Using file \'{file}\'...') | ||
|
||
# Source 1: WebM Streams/Formats | ||
logging.info('Retrieving WebmM stream/format data...') | ||
webm_format = TestWebm.get_webm_format(file) | ||
|
||
# Source 2: Extracted audio stream, needed for verifying audio bitrate | ||
logging.info('Retrieving extracted audio stream/format data...') | ||
audio_format = TestWebm.get_audio_format(file) | ||
|
||
# Source 3: Loudness stats | ||
logging.info('Retrieving loudness data...') | ||
loudness_stats = TestWebm.get_loudness_stats(file) | ||
|
||
# Source 4: Index of streams by codec type | ||
video_index = TestWebm.get_stream_index(webm_format, 'video') | ||
audio_index = TestWebm.get_stream_index(webm_format, 'audio') | ||
|
||
if logging.root.isEnabledFor(logging.DEBUG): | ||
logging.debug('Dumping test data...') | ||
logging.debug(f'video_index: \'{video_index}\'') | ||
logging.debug(f'audio_index: \'{audio_index}\'') | ||
logging.debug(f'webm_format[streams][0][codec_type]: \'{webm_format["streams"][0]["codec_type"]}\'') | ||
logging.debug(f'webm_format[streams][1][codec_type]: \'{webm_format["streams"][1]["codec_type"]}\'') | ||
logging.debug(f'len(webm_format[streams]): \'{len(webm_format["streams"])}\'') | ||
logging.debug(f'webm_format[format][format_name]: \'{webm_format["format"]["format_name"]}\'') | ||
logging.debug(f'webm_format[format][bit_rate]): \'{webm_format["format"]["bit_rate"]}\'') | ||
logging.debug(f'webm_format[streams][video_index][height]: ' | ||
f'\'{webm_format["streams"][video_index]["height"]}\'') | ||
logging.debug(f'webm_format[chapters]: \'{webm_format["chapters"]}\'') | ||
logging.debug(f'webm_format[streams][video_index][codec_name]: ' | ||
f'\'{webm_format["streams"][video_index]["codec_name"]}\'') | ||
logging.debug(f'webm_format[streams][video_index][pix_fmt]: ' | ||
f'\'{webm_format["streams"][video_index]["pix_fmt"]}\'') | ||
logging.debug(f'webm_format[streams][video_index].get(color_space): ' | ||
f'\'{webm_format["streams"][video_index].get("color_space")}\'') | ||
logging.debug(f'webm_format[streams][video_index].get(color_transfer): ' | ||
f'\'{webm_format["streams"][video_index].get("color_transfer")}\'') | ||
logging.debug(f'webm_format[streams][video_index].get(color_primaries): ' | ||
f'\'{webm_format["streams"][video_index].get("color_primaries")}\'') | ||
logging.debug(f'webm_format[streams][video_index][avg_frame_rate]: ' | ||
f'\'{webm_format["streams"][video_index]["avg_frame_rate"]}\'') | ||
logging.debug(f'webm_format[streams][audio_index][codec_name]: ' | ||
f'\'{webm_format["streams"][audio_index]["codec_name"]}\'') | ||
logging.debug(f'[loudness_stats] input_i: ' | ||
f'\'{loudness_stats["input_i"]}\', ' | ||
f'input_lra: \'{loudness_stats["input_lra"]}\', ' | ||
f'input_tp: \'{loudness_stats["input_tp"]}\', ' | ||
f'input_thresh: \'{loudness_stats["input_thresh"]}\', ' | ||
f'target_offset: \'{loudness_stats["target_offset"]}\'') | ||
logging.debug(f'audio_format[format][bitrate]: \'{audio_format["format"]["bit_rate"]}\'') | ||
logging.debug(f'webm_format[streams][audio_index][sample_rate]: ' | ||
f'\'{webm_format["streams"][audio_index]["sample_rate"]}\'') | ||
logging.debug(f'webm_format[streams][audio_index][channels]: ' | ||
f'\'{webm_format["streams"][audio_index]["channels"]}\'') | ||
logging.debug(f'webm_format[streams][audio_index][channel_layout]: ' | ||
f'\'{webm_format["streams"][audio_index]["channel_layout"]}\'') | ||
|
||
logging.info('Running Tests...') | ||
test_loader = unittest.TestLoader() | ||
test_names = test_loader.getTestCaseNames(TestWebm) | ||
|
||
suite = unittest.TestSuite() | ||
for test_name in test_names: | ||
suite.addTest(TestWebm(test_name, webm_format, audio_format, loudness_stats, video_index, audio_index)) | ||
|
||
unittest.TextTestRunner().run(suite) | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
main() | ||
except KeyboardInterrupt: | ||
logging.error('Exiting after keyboard interrupt') |
Oops, something went wrong.