-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests of autoprocessing #5
Open
rpanderson
wants to merge
9
commits into
philipstarkey:master
Choose a base branch
from
rpanderson:test_example_screencast
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
73937df
Add tests of autoprocessing example_screencast.mp4
rpanderson 796620a
Use GitHub actions to perform the tests
rpanderson 096e764
Only run release workflow for philipstarkey/autoscrub
rpanderson 89e6d80
Use matrix strategy to test on different Python versions
rpanderson 4773ee5
Use backport of pathlib if python_version < 3
rpanderson 34574cb
Cast Path objects to str for PY2 where appropriate
rpanderson f173b6d
Test on ubuntu-latest and windows-latest
rpanderson fce4588
Include macos in test and set pytest-timeout of 150 seconds
rpanderson 4c462f3
Replace filecmp.cmp with equality check using universal line endings
rpanderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,40 @@ | ||
name: Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: [2.7, 3.8] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
pip install -e . | ||
# pip install -r requirements.txt | ||
- name: Install FFmpeg (Linux) | ||
if: startsWith(matrix.os, 'ubuntu') | ||
run: | | ||
sudo add-apt-repository ppa:jonathonf/ffmpeg-4 | ||
sudo apt-get update | ||
sudo apt-get install ffmpeg | ||
- name: Install FFmpeg (Windows) | ||
if: startsWith(matrix.os, 'windows') | ||
run: choco install ffmpeg | ||
- name: Install FFmpeg (macOS) | ||
if: startsWith(matrix.os, 'macos') | ||
run: brew install ffmpeg | ||
- name: Test with pytest | ||
run: | | ||
pip install pytest pytest-timeout | ||
pytest |
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
click>=6.0,<7.0 | ||
six | ||
requests | ||
subprocess32; python_version < '3.2' | ||
subprocess32; python_version < '3.2' | ||
pathlib2; python_version < '3' |
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,3 @@ | ||
[tool:pytest] | ||
testpaths = tests | ||
timeout = 150 |
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
Binary file not shown.
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,28 @@ | ||
[0:v]trim=0.0000:0.2530,setpts=PTS-STARTPTS[v1]; | ||
[0:v]trim=0.2530:1.9990,setpts=(PTS-STARTPTS)/8[v2]; | ||
[0:v]trim=1.9990:6.4611,setpts=PTS-STARTPTS[v3]; | ||
[0:v]trim=6.4611:16.8058,setpts=(PTS-STARTPTS)/8[v4]; | ||
[0:v]trim=16.8058:19.3400,setpts=PTS-STARTPTS[v5]; | ||
[0:v]trim=19.3400:32.5301,setpts=(PTS-STARTPTS)/8[v6]; | ||
[0:v]trim=32.5301:45.8549,setpts=PTS-STARTPTS[v7]; | ||
[0:v]trim=45.8549:56.1694,setpts=(PTS-STARTPTS)/8[v8]; | ||
[0:v]trim=56.1694:59.8605,setpts=PTS-STARTPTS[v9]; | ||
[0:v]trim=59.8605:64.8073,setpts=(PTS-STARTPTS)/8[v10]; | ||
[0:v]trim=64.8073:78.2927,setpts=PTS-STARTPTS[v11]; | ||
[0:v]trim=78.2927:81.6206,setpts=(PTS-STARTPTS)/8[v12]; | ||
[0:v]trim=start=81.6206,setpts=PTS-STARTPTS[v13]; | ||
[0:a]atrim=0.0000:0.2530,asetpts=PTS-STARTPTS[a1]; | ||
[0:a]atrim=0.2530:1.9990,asetpts=PTS-STARTPTS,atempo=2.0,atempo=2.0,atempo=2.0,volume=1.000[a2]; | ||
[0:a]atrim=1.9990:6.4611,asetpts=PTS-STARTPTS[a3]; | ||
[0:a]atrim=6.4611:16.8058,asetpts=PTS-STARTPTS,atempo=2.0,atempo=2.0,atempo=2.0,volume=1.000[a4]; | ||
[0:a]atrim=16.8058:19.3400,asetpts=PTS-STARTPTS[a5]; | ||
[0:a]atrim=19.3400:32.5301,asetpts=PTS-STARTPTS,atempo=2.0,atempo=2.0,atempo=2.0,volume=1.000[a6]; | ||
[0:a]atrim=32.5301:45.8549,asetpts=PTS-STARTPTS[a7]; | ||
[0:a]atrim=45.8549:56.1694,asetpts=PTS-STARTPTS,atempo=2.0,atempo=2.0,atempo=2.0,volume=1.000[a8]; | ||
[0:a]atrim=56.1694:59.8605,asetpts=PTS-STARTPTS[a9]; | ||
[0:a]atrim=59.8605:64.8073,asetpts=PTS-STARTPTS,atempo=2.0,atempo=2.0,atempo=2.0,volume=1.000[a10]; | ||
[0:a]atrim=64.8073:78.2927,asetpts=PTS-STARTPTS[a11]; | ||
[0:a]atrim=78.2927:81.6206,asetpts=PTS-STARTPTS,atempo=2.0,atempo=2.0,atempo=2.0,volume=1.000[a12]; | ||
[0:a]atrim=start=81.6206,asetpts=PTS-STARTPTS[a13]; | ||
[v1][a1][v2][a2][v3][a3][v4][a4][v5][a5][v6][a6][v7][a7][v8][a8][v9][a9][v10][a10][v11][a11][v12][a12][v13][a13]concat=n=13:v=1:a=1[v][an]; | ||
[an]volume=4.8dB[a] |
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,81 @@ | ||
import os | ||
import filecmp | ||
import six | ||
import autoscrub | ||
|
||
if six.PY3: | ||
from pathlib import Path | ||
else: | ||
# backported pathlib module | ||
from pathlib2 import Path | ||
|
||
TEST_VIDEO_INPUT = "example_screencast.mp4" | ||
TEST_VIDEO_OUTPUT = "example_screencast_scrub.mp4" | ||
VALID_FILTERGRAPH = "example_screencast.txt" | ||
VALID_DURATION = 48.57 | ||
VALID_LOUDNESS = { | ||
"I": -18.1, | ||
"Threshold": -39.2, | ||
"LRA": 7.3, | ||
"LRA low": -23.5, | ||
"LRA high": -16.2, | ||
} | ||
|
||
|
||
os.chdir(str(Path(__file__).parent.absolute())) | ||
|
||
|
||
def cmp_lines(path_1, path_2): | ||
"""Check file equality using universal line endings. | ||
See: https://stackoverflow.com/a/23038606 | ||
""" | ||
l1 = l2 = True | ||
with open(path_1, "r") as f1, open(path_2, "r") as f2: | ||
while l1 and l2: | ||
l1 = f1.readline() | ||
l2 = f2.readline() | ||
if l1 != l2: | ||
return False | ||
return True | ||
|
||
|
||
def test_autoprocess(input=TEST_VIDEO_INPUT, filtergraph=VALID_FILTERGRAPH): | ||
"""Runs autoscrub autoprocess --debug on TEST_VIDEO_INPUT | ||
|
||
Checks stdout and compares resulting filtergraph to known valid version | ||
""" | ||
# Create output path | ||
suffix = Path(input).suffix | ||
output = input.replace(suffix, "_scrub" + suffix) | ||
|
||
# Run autoscrub autoprocess --debug input output | ||
p = autoscrub._agnostic_Popen( | ||
["autoscrub", "autoprocess", "--debug", input, output] | ||
) | ||
_, stderr = autoscrub._agnostic_communicate(p) | ||
|
||
# Check stdout | ||
stdout = p.stdout.readlines() | ||
assert stdout[-4].strip() == b"[autoscrub:info] Done!" | ||
|
||
# Check filtergraph | ||
tmp = Path(stdout[-1].decode("utf8").split("at:")[-1].strip()) | ||
assert cmp_lines(VALID_FILTERGRAPH, str(tmp)) | ||
|
||
|
||
def test_duration(): | ||
"""Checks duration of processed test video | ||
|
||
Checks duration of processed test video produced by autoscrub autoprocess | ||
is as expected. | ||
""" | ||
assert autoscrub.getDuration(TEST_VIDEO_OUTPUT) == VALID_DURATION | ||
|
||
|
||
def test_loudness(): | ||
"""Checks loudness properties of processed test video | ||
|
||
Checks loudness of test video produced by autoscrub autoprocess | ||
is as expected. | ||
""" | ||
assert autoscrub.getLoudness(TEST_VIDEO_OUTPUT) == VALID_LOUDNESS |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #2 in which processing continued indefinitely, a timeout is essential here, akin to
subprocess.Popen.communicate
. @philipstarkey, is this something that could/should be added toautoscrub._agnostic_communicate
or should I be using something else. here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I've set a timeout on the test runner, using
pytest-timeout
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why, but the test is stalling on Windows at this point (both locally and on Python 2.7 and 3.8).