Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Enhanced transcoding integration tests with ffprobe report #4249

Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c8c33ba
Add a dependency on parameterized
cameel Apr 11, 2019
e0af432
StreamOperator: Implement get_metadata()
pawelkisielewicz Mar 27, 2019
2734e08
StreamOperator.get_metadata(): Detect missing and invalid data return…
cameel Apr 11, 2019
10f372d
ffprobe_report: Implement FuzzyDuration and FuzzyInt
pawelkisielewicz Mar 27, 2019
20c0e30
ffprobe_report: Implement FfprobeFormatReport
pawelkisielewicz Mar 27, 2019
0f1e416
ffprobe_report: Implement stream report classes with a common base class
pawelkisielewicz Apr 8, 2019
c16489c
ffprobe_report: Add FfprobeFormatReport.stream_reports property
pawelkisielewicz Apr 8, 2019
ba74ec4
ffprobe_report: Cache stream reports in the object instead of rebuild…
cameel Apr 10, 2019
3a198ea
ffprobe_report: Add select_streams()
cameel Apr 17, 2019
922bde1
ffprobe_report: Just fail if codec_type is missing
cameel Apr 12, 2019
343a2bc
ffprobe_report: Don't duplicate return value if both resolution and w…
pawelkisielewicz Apr 11, 2019
0d45580
ffprobe_report: Rewrite diff() methods
cameel Apr 10, 2019
2e9a852
ffprobe_report: Add __repr__ for format and stream report classes
pawelkisielewicz Apr 11, 2019
3d63c01
ffprobe_report: Implement number_if_possible(), fuzzy_duration_if_pos…
cameel Apr 12, 2019
49f1d55
ffprobe_report: Convert numeric properties to numbers when possible
cameel Apr 12, 2019
1c08ad7
ffprobe_report tests: Add file with sample raw reports to test Ffprob…
pawelkisielewicz Apr 11, 2019
fe1624b
ffprobe_report tests: Add raw report with mpeg4 video codec and 'nb_f…
pawelkisielewicz Apr 11, 2019
4c5a667
ffprobe_report tests: Unit tests for FfprobeFormatReport
pawelkisielewicz Apr 11, 2019
9771329
StreamOperator.get_metadata(): accept work_dir and output_dir as para…
cameel Apr 11, 2019
687f7c1
ffprobe_report: Accept path to the temporary directory in FfprobeForm…
cameel Apr 15, 2019
21fa048
ffprobe_report: Make video_paths a list in build() rather than variab…
cameel Apr 15, 2019
b0a9b90
Implement FfprobeReportSet
cameel Apr 13, 2019
e70febc
Add tests for FfprobeReportSet
pawelkisielewicz May 10, 2019
4fb8ec0
Add more tests for FfprobeReport
pawelkisielewicz Apr 24, 2019
d994f17
ffprobe_report: Add 'excludes' parameter to diff()
cameel Apr 17, 2019
677d60c
ffprobe_report_set: Make information about mismatched streams more co…
cameel Apr 19, 2019
25f5792
test_ffmpegintegration: Extract task definition into _create_task_def…
pawelkisielewicz Mar 26, 2019
3617bcf
test_ffmpegintegration: Extract part of the code into an intermediate…
pawelkisielewicz Mar 26, 2019
a982f2e
test_ffmpegintegration: Add optional parameters to _create_task_def_f…
pawelkisielewicz Apr 9, 2019
1c073fa
Implement SimulatedTranscodingOperation
cameel Apr 15, 2019
33297a2
Add tests for SimulatedTranscodingOperation
pawelkisielewicz May 2, 2019
b1454fb
ffprobe_report: Extract a function for parsing frame_rate
cameel Apr 26, 2019
b57580e
SimulatedTranscodingOperation: Use parse_ffprobe_frame_rate() for the…
cameel Apr 26, 2019
82928de
test_ffmpegintegration: Codec change tests
cameel Apr 11, 2019
e706f51
test_ffmpegintegration: Tests for splitting into various numbers of s…
cameel Apr 11, 2019
d33410c
test_ffmpegintegration: Explicitly set codec and resolution in codec …
cameel May 27, 2019
e05e528
test_ffmpegintegration: Don't compare bitrate and frame_count in code…
cameel May 27, 2019
cbd45d1
test_ffmpegintegration: Disable maxDiff in FfmpegIntegrationTestCase
cameel Apr 13, 2019
1475f3c
testutils: Define a custom exception type for a failing Docker job in…
cameel Apr 15, 2019
d4dd58f
test_ffmpegintegration: Resolution change tests
cameel Apr 11, 2019
b37a669
test_ffmpegintegration: Explicitly set codec in resolution change tests
cameel May 27, 2019
02cada9
test_ffmpegintegration: Don't compare bitrate in resolution change tests
cameel May 27, 2019
d8e2b98
test_ffmpegintegration: Frame rate change tests
cameel Apr 11, 2019
e583330
test_ffmpegintegration: Explicitly set codec and resolution in frame …
cameel May 27, 2019
8d81b86
test_ffmpegintegration: Don't compare bitrate in frame rate change tests
cameel May 27, 2019
3e93930
Merge TestffmpegIntegration and FfmpegIntegrationTestCase back into a…
cameel May 29, 2019
61fc541
File structure fix - move files related to ffprobe reports to utils d…
pawelkisielewicz Jun 3, 2019
435172a
Save FfprobeReportSet to a file in the test directory
pawelkisielewicz Jun 4, 2019
3427f4f
Hard-coding important fixture values in tests instead of verifying th…
pawelkisielewicz Jun 5, 2019
535aaae
Constants for reason field in the diff
pawelkisielewicz Jun 5, 2019
0e40a02
Rename streams: modified -> expected, original -> actual
pawelkisielewicz Jun 5, 2019
9e325a9
simulated_transcoding_operation: Fix output file name generation
cameel May 29, 2019
2816ee9
TestFfprobeFormatReport: Enable showing longer diffs in tests
cameel Jun 6, 2019
fd476df
Make == in FuzzyDuration and FuzzyInt still take tolerance into accou…
cameel Apr 26, 2019
03d760f
SimulatedTranscodingOperation: Make _set_override() public
cameel Apr 26, 2019
6b180d2
simulated_transcoding_operation: Put container immediately after code…
cameel Jun 7, 2019
be32a74
simulated_transcoding_operation: Make it possible not to include some…
cameel Jun 10, 2019
5d7924d
test_ffmpegintegration: Use dont_include_in_option_description to get…
cameel Jun 10, 2019
271a017
Move DiffReason to ffprobe_report
cameel Jun 11, 2019
52f84af
Replace all remaining hard-coded reason values with DiffReason
cameel Jun 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion apps/transcoding/ffmpeg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from pathlib import Path
import shutil
from typing import Optional
from typing import List, Optional

from apps.transcoding import common
from apps.transcoding.common import ffmpegException
Expand All @@ -30,6 +30,7 @@ class Commands(enum.Enum):
SPLIT = ('split', 'split-results.json')
TRANSCODE = ('transcode', '')
MERGE = ('merge', '')
COMPUTE_METRICS = ('compute-metrics', '')


class StreamOperator:
Expand Down Expand Up @@ -191,3 +192,62 @@ def _specify_dir_mapping(output, temporary, resources, logs, work):
temporary=temporary,
resources=resources,
logs=logs, work=work)

def get_metadata(self,
input_files: List[str],
resources_dir: str,
work_dir: str,
output_dir: str) -> dict:

assert os.path.isdir(resources_dir)
assert all([
os.path.isfile(os.path.join(resources_dir, input_file))
for input_file in input_files
])

try:
os.makedirs(output_dir, exist_ok=True)
except OSError:
raise ffmpegException(
"Failed to prepare directory structure for get_metadata")

metadata_requests = [{
'video': input_file,
'output': f'metadata-logs-{os.path.splitext(input_file)[0]}.json'
} for input_file in input_files]

extra_data = {
'entrypoint': FFMPEG_ENTRYPOINT,
'command': Commands.COMPUTE_METRICS.value[0],
'metrics_params': {
'metadata': metadata_requests,
},
}

dir_mapping = DockerTaskThread.specify_dir_mapping(
output=output_dir,
temporary=work_dir,
resources=resources_dir,
logs=work_dir,
work=work_dir)

logger.info('Obtaining video metadata.')
logger.debug('Command params: %s', extra_data)

job_result = self._do_job_in_container(dir_mapping, extra_data)
if 'data' not in job_result:
raise ffmpegException(
"Failed to obtain video metadata. "
"'data' not found in the returned JSON.")

if len(job_result['data']) < len(input_files):
raise ffmpegException(
"Failed to obtain video metadata. "
"Missing output for at least one input file.")

if len(job_result['data']) > len(input_files):
raise ffmpegException(
"Failed to obtain video metadata. Too many results.")

logger.info('Video metadata obtained successfully!')
return job_result
6 changes: 5 additions & 1 deletion golem/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
logger = logging.getLogger(__name__)


class DockerTestJobFailure(Exception):
pass


class TestTaskManager(TaskManager):
def __init__(self, node, keys_auth, root_path, config_desc: ClientConfigDescriptor, tasks_dir="tasks",
task_persistence=False, apps_manager=AppsManager(), finished_cb=None):
Expand Down Expand Up @@ -482,7 +486,7 @@ def _run_test_job(self, task, root_dir, params):
self._log_docker_logs(dtt)

if dtt.error:
raise Exception(dtt.error_msg)
raise DockerTestJobFailure(dtt.error_msg)

return dtt.result.get('data')

Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ idna==2.5
isort==4.3.4
lazy-object-proxy==1.3.1
mccabe==0.6.1
parameterized==0.7.0
pluggy==0.6.0
py==1.5.3
pycodestyle==2.4.0
Expand Down
1 change: 1 addition & 0 deletions requirements-test_to-freeze.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ factory-boy==2.9.2
Faker==0.8.9
flake8
freezegun==0.3.11
parameterized==0.7.0
pylint==1.9.2
pytest-cov
pytest==3.3.1
Loading