Skip to content

Commit a942771

Browse files
authored
Merge pull request #37 from amiaopensource/develop
Develop
2 parents 4d821d3 + fdaccfb commit a942771

File tree

17 files changed

+1340
-445
lines changed

17 files changed

+1340
-445
lines changed

.github/workflows/tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
on: [push, pull_request]
2+
name: Supported Python Compatibility Test
3+
jobs:
4+
build:
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest, macos-latest, windows-2019]
9+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
10+
include:
11+
- os: macos-latest
12+
- os: ubuntu-latest
13+
- os: windows-2019
14+
fail-fast: false
15+
name: Python ${{ matrix.python-version }} ${{ matrix.os }} build
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
cache: 'pip' # caching pip dependencies
22+
- name: Install requirements
23+
run: |
24+
pip install tox
25+
- uses: actions/github-script@v7
26+
id: tox-env
27+
with:
28+
result-encoding: string
29+
script: |
30+
const frontend = "${{matrix.frontend}}"
31+
const toxEnv = "py${{matrix.python-version}}".replace('.','')
32+
if(frontend === ""){
33+
return toxEnv
34+
}
35+
return "py${{matrix.python-version}}".replace('.','') + "-${{matrix.frontend}}"
36+
- name: Run tox
37+
run: tox -e ${{ steps.tox-env.outputs.result }}

README.md

Lines changed: 173 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,211 @@
1-
scripts for automating QCTools actions
21

3-
qct-parse.py | find frames that are beyond thresholds for saturation, luma, etc
2+
# QCTools Automation Scripts
3+
4+
This repository contains scripts for automating analysis of QCTools reports.
5+
6+
## Overview
7+
8+
### Install from source:
9+
10+
* Create a new Python Virtual Environment for qct_parse
11+
* Unix based (Mac or Linux):
12+
`python3 -m venv name_of_env`
13+
* Windows:
14+
`py -m venv name_of_env`
15+
(where 'name_of_env' is replaced with the name of your virtual environment)
16+
* Activate virtual env
17+
* Unix based (Mac or Linux):
18+
`source ./name_of_env/bin/activate`
19+
* Windows:
20+
`name_of_env\scripts\activate`
21+
* Install Package
22+
* Navigate to the repo root directory `path/to/qct-parse/`
23+
* Run the command:
24+
`python -m pip install .`
25+
26+
### Test Code
27+
28+
If you intend to develop the code for your proposes or contribute to the open source project, a test directory is provided in the repo.
29+
* Activate virtual env (see Install from source)
30+
* Install pytest
31+
`pip install pytest`
32+
* Run tests
33+
`python -m pytest`
34+
35+
### Building the documentation
36+
* Activate virtual env (see Install from source)
37+
* Install sphinx and myst-parser
38+
`pip install sphinx myst-parser`
39+
* Run sphinx-build command
40+
`sphinx-build ./docs ./dist/docs`
41+
42+
43+
### Commands:
44+
45+
- **`qct-parse -i/--input [path to QCTools report] [optional arguments]`**
46+
Finds frames that exceed thresholds for QCTool tag(s). Full list of command line arguments below.
47+
48+
---
49+
50+
# `qct-parse`
51+
52+
Run a single tag against a supplied value or multiple tags using a profile.
53+
54+
## Arguments
455

5-
makeqctoolsreport.py | make a qctools.xml.gz report for input video file
56+
| Argument | Description |
57+
|-----------------------------|-------------------------------------------------------------------------------------------------------|
58+
| `-h`, `--help` | Show this help message and exit |
59+
| `-i`, `--input` | Path to the input `qctools.xml.gz` or `qctools.mkv` file |
60+
| `-t`, `--tagname` | The tag name you want to test (e.g., `SATMAX`); see table of tag names below for list |
61+
| `-o`, `--over` | Threshold overage number |
62+
| `-u`, `--under` | Threshold under number |
63+
| `-p`, `--profile` | Compare frame data against tag values from `config.txt`. Use `-p default` for QCTools default values |
64+
| `-buff`, `--buffSize` | Circular buffer size. If even, defaults to the next odd number (default: 11) |
65+
| `-te`, `--thumbExport` | Enable/disable thumbnail export (default: off) |
66+
| `-ted`, `--thumbExportDelay`| Minimum frames between exported thumbnails (default: 9000) |
67+
| `-tep`, `--thumbExportPath` | Path to thumbnail export. Uses input base-path if omitted |
68+
| `-ds`, `--durationStart` | Start analysis from this time (seconds, equivalent to ffmpeg `-ss`) |
69+
| `-de`, `--durationEnd` | End analysis after this time (seconds, equivalent to ffmpeg `-t`) |
70+
| `-bd`, `--barsDetection` | Enable/disable bar detection (default: off) |
71+
| `-be`, `--barsEvaluation` | Use peak values from color bars as 'profile' if bars are detected |
72+
| `-pr`, `--print` | Print over/under frame data to console (default: off) |
73+
| `-q`, `--quiet` | Suppress ffmpeg output in console (default: off) |
674

7-
# qct-parse.py
75+
## Tags
876

9-
You can run a single tag against a supplied value from the CLI or run multiple tags against values set in the qct-parse_config.txt file.
77+
| Tag category | Tag names |
78+
|-----------------------------|-------------------------------------------------------------------------------------------------------|
79+
| [YUV values](https://bavc.github.io/qctools/filter_descriptions.html#yuv) | `YMIN,YLOW,YAVG,YHIGH,YMAX`<br>`UMIN,ULOW,UAVG,UHIGH,UMAX`<br>`VMIN,VLOW,VAVG,VHIGH,VMAX` |
80+
| [YUV values (difference)](https://bavc.github.io/qctools/filter_descriptions.html#diff) | `YDIF,UDIF,VDIF` |
81+
| [Saturation values](https://bavc.github.io/qctools/filter_descriptions.html#saturation) | `SATMIN,SATLOW,SATAVG,SATHIGH,SATMAX` |
82+
| [Hue values](https://bavc.github.io/qctools/filter_descriptions.html#hue) | `HUEMED,HUEAVG` |
83+
| [Temporal outliers](https://bavc.github.io/qctools/filter_descriptions.html#tout) | `TOUT` |
84+
| [Vertical line repetitions](https://bavc.github.io/qctools/filter_descriptions.html#vrep) | `VREP` |
85+
| [Broadcast range](https://bavc.github.io/qctools/filter_descriptions.html#brng) | `BRNG` |
86+
| [Mean square error fields](https://bavc.github.io/qctools/filter_descriptions.html#msef) | `mse_y,mse_u,mse_v,mse_avg` |
87+
| [Peak signal to noise ratio fields](https://bavc.github.io/qctools/filter_descriptions.html#psnrf) | `psnr_y,psnr_u,psnr_v,psnr_avg` |
1088

11-
## arguments
12-
-h, --help | show this help message and exit
89+
## Examples
1390

14-
-i, --input | the path to the input qctools.xml.gz file
15-
16-
-t, --tagname | the tag name you want to test, e.g. SATMAX
17-
18-
-o, --over | the threshold overage number
19-
20-
-u, --under | the threshold under number
21-
22-
-p, --profile | compare frame data aginst tag values from config.txt file, us "-p default" for values from QCTools docs
23-
24-
-buff, --buffSize | Size of the circular buffer. if user enters an even number it'll default to the next largest number to make it odd, default size 11
25-
26-
-te, --thumbExport | export thumbnails on/ off, default off
27-
28-
-ted, --thumbExportDelay | minimum frames between exported thumbs, default 9000
29-
30-
-tep, --thumbExportPath | Path to thumb export. if ommitted, uses the input base-path
31-
32-
-ds, --durationStart | the duration in seconds to start analysis (ffmpeg equivalent -ss)
33-
34-
-de, --durationEnd | the duration in seconds to stop analysis (ffmpeg equivalent -t)
35-
36-
-bd, --barsDetection | bar detection on/ off, default off
37-
38-
-pr, --print | print over/under frame data to console window, default off
39-
40-
-q, --quiet | print ffmpeg output to console window, default off
91+
### Run single tag tests
92+
```bash
93+
qct-parse -t SATMAX -o 235 -t YMIN -u 16 -i /path/to/report.mkv.qctools.xml.gz
94+
```
4195

96+
### Run bars detection using default QCTools profile
97+
```bash
98+
qct-parse -bd -p default -i /path/to/report.mkv.qctools.mkv
99+
```
42100

43-
## examples
101+
### Export thumbnails of frames beyond threshold
102+
```bash
103+
qct-parse -p default -te -tep /path/to/export/folder -i /path/to/report.mkv.qctools.xml.gz
104+
```
44105

45-
### single tags
106+
### Use peak values from detected color bars as thresholds
107+
```bash
108+
qct-parse -bd -be -i /path/to/report.mkv.qctools.xml.gz
109+
```
46110

47-
python qct-parse.py -t SATMAX -o 235 -t YMIN -u 16 -i /path/to/report.mkv.qctools.xml.gz
111+
## Input files
48112

49-
### run bars against default profile from QCTools docs
113+
qct-parse.py will work with the following QCTools report formats:
114+
```
115+
qctools.xml.gz
116+
qctools.mkv
117+
```
50118

51-
python qct-parse.py -bd -p default -i /path/to/reportsmkv.qctools.xml.gz
119+
If the qctools.xml.gz report is in an MKV attachment, the qctools.xml.gz report file will be extracted and saved as a separate file.
52120

53-
### print out thumbnails of frames beyond threshold
121+
Both 8-bit and 10-bit values are supported. The bit depth will be detected automatically, and does not need to be specified.
54122

55-
python qct-parse.py -p default -te -tep C:\path\to\export\folder -i C:\path\to\the\report.mkv.qctools.xml.gz
123+
## Config Files
56124

57-
## some handy applescript to grep individual tags
125+
The provided profiles are:
126+
* default
127+
* highTolerance
128+
* midTolerance
129+
* lowTolerance
58130

59-
### just percentages
131+
Each of these profiles contain the following tags with a corresponding threshold:
132+
`YLOW, YMAX, UMIN, UMAX, VMIN, VMAX, SATMAX, TOUT, VREP`
60133

61-
python ./qct-parse.py -i input.mxf.qctools.xml.gz -bd -p lowTolerance | grep 'YMAX' | awk 'NR==1 {print $3}'
134+
The profiles are stored in the config.txt files. Please note that there is a separate config.txt for 8-bit and 10-bit values.
62135

63-
### total number of frame failures
136+
The process for providing user supplied profiles is in development.
137+
Currently, if you wish to create your own profile, you will need to create your own config directory and `config.txt` file.
138+
There is a environmental variable at the top of qct-parse.py which can be used to reset the config directory:
139+
```bash
140+
CONFIG_ENVIRONMENT_VARIABLE_NAME = 'QCT_PARSE_CONFIG_DIRECTORY'
141+
```
142+
Simply place the full path to the user created config *directory* in place of 'QCT_PARSE_CONFIG_DIRECTORY'
64143

65-
python ./qct-parse.py -i input.mxf.qctools.xml.gz -bd -p lowTolerance | grep 'YMAX' | awk 'NR==1 {print $2}'
144+
## Thumbnails
66145

67-
## dependencies
146+
Thumbnails of failed frames will be exported if the `-te` flag is invoked.
68147

69-
Python 2.7.x.
148+
In order to export thumbnails, the QCTools report must be in the same directory as the video file it is describing, and must have the same file name as the report (excluding the `qctools.xml.gz`).
70149

71-
Requires that [lxml](http://lxml.de/) is installed on your system. For more info on how it's used, see [here](http://www.ibm.com/developerworks/library/x-hiperfparse/)
150+
If you would like to provide a path for exporting thumbnails, you can do so using the `-tep` flag.
151+
Otherwise, thumbnails will automatically be created in the same directory as the video file and QCTools report, in a new directory.
72152

73-
### For Windows users:
153+
When running qct-parse with a profile, the thumbnails will be placed in a directory named `ThumbExports`.
154+
When run against single tags the directory will be named [TAG NAME].[THRESHOLD]
74155

75-
We **strongly** suggest using the pre-compiled installer found [here](https://pypi.python.org/pypi/lxml/3.3.3#downloads)
156+
## Logging
76157

77-
### For Mac users:
158+
A log file is created with the same name as the input file but with a '.log' extension.
159+
For example: `some_video_file.mkv.qctools.xml.gz.log`
78160

79-
Try pip first, then try the macport. More info can be found [here](http://lxml.de/installation.html)
161+
Log files contain every instance of values over the specified threshold. For example:
162+
`2024-10-03 17:02:35,737 SATMAX is over 181.02 with a value of 698.0 at duration 00:00:16.4500`
80163

81-
# makeqctoolsreport.py
164+
---
82165

83-
python port of Morgan's [makeqctoolsreport.as](https://github.com/iamdamosuzuki/QCToolsReport)
166+
### Legacy Commands:
84167

168+
Not in active development. Please file an issue if you are interested in using these.
85169

86-
## example
170+
#### `makeqctoolsreport`
87171

88-
python makeqctoolsreport.py /path/to/input.mxf
172+
A Python port of Morgan’s [makeqctoolsreport.as](https://github.com/iamdamosuzuki/QCToolsReport), this script generates QCTools `.xml.gz` reports from input video files.
89173

90-
## contributors
174+
Example Usage:
175+
```bash
176+
makeqctoolsreport /path/to/input.mxf
177+
```
91178

92-
@eddycolloton
179+
#### `overcatch`
93180

94-
@CoatesBrendan
181+
A script from the original qct-parse development for running a report against multiple profiles.
95182

96-
@av_morgan
183+
Example Usage:
184+
```bash
185+
overcatch /path/to/input.mxf
186+
```
97187

98-
## maintainers
188+
---
99189

100-
@av_morgan
190+
## Dependencies
101191

102-
@eddycolloton
192+
Ensure Python 3.x.x is installed.
193+
194+
Requires FFmpeg.
195+
196+
This tool uses the `lxml` python module which is automatically installed with the qct-parse package.
197+
198+
For more information on `lxml` usage, check out the [lxml documentation](http://lxml.de/).
199+
200+
---
201+
202+
## Contributors
203+
204+
- [@eddycolloton](https://github.com/eddycolloton)
205+
- [@CoatesBrendan](https://github.com/CoatesBrendan)
206+
- [@av_morgan](https://github.com/av_morgan)
207+
208+
## Maintainer
209+
210+
- [@av_morgan](https://github.com/av_morgan)
211+
- [@eddycolloton](https://github.com/eddycolloton)

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = 'qct-parse'
10+
copyright = '2024, AMIA Open-Source'
11+
author = 'AMIA Open-Source'
12+
13+
# -- General configuration ---------------------------------------------------
14+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
15+
16+
extensions = ['myst_parser']
17+
18+
templates_path = ['_templates']
19+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
20+
21+
source_suffix = {
22+
'.rst': 'restructuredtext',
23+
'.txt': 'markdown',
24+
'.md': 'markdown',
25+
}
26+
27+
# -- Options for HTML output -------------------------------------------------
28+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
29+
30+
html_theme = 'alabaster'
31+
html_static_path = ['_static']

docs/development.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Development Information
2+
3+
## Configure Development Environment
4+
5+
* Create a new Python Virtual Environment for qct_parse
6+
* Unix based (Mac or Linux):
7+
`python3 -m venv name_of_env`
8+
* Windows:
9+
`py -m venv name_of_env`
10+
(where 'name_of_env' is replaced with the name of your virtual environment)
11+
* Activate virtual env
12+
* Unix based (Mac or Linux):
13+
`source ./name_of_env/bin/activate`
14+
* Windows:
15+
`name_of_env\scripts\activate`
16+
* Install Package as editable package
17+
* Navigate to the repo root directory `path/to/qct-parse/`
18+
* Run the command:
19+
`python -m pip install -e .`
20+
21+
## Run Tests
22+
23+
If you intend to develop the code for your proposes or contribute to the open source project, a test directory is provided in the repo.
24+
* Activate virtual env (see Configure Development Environment)
25+
* Install pytest
26+
`pip install pytest`
27+
* Run tests
28+
`python -m pytest`
29+

0 commit comments

Comments
 (0)