Skip to content

Commit

Permalink
Fix find_media_errors.py to consider time and compute limits for both…
Browse files Browse the repository at this point in the history
… error cases
  • Loading branch information
double16 committed Nov 12, 2024
1 parent 1c5a769 commit c9ad26b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dvrprocess/find_media_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ def media_errors_generator(media_paths: list[str], media_roots: list[str],
continue

cached_error_count = config.get_file_config_option(filepath, 'error', 'count')
if cached_error_count:
error_count = int(cached_error_count)
elif cache_only:
continue
else:
cached_eas_detected = config.get_file_config_option(filepath, 'error', 'eas')
if cached_error_count is None or cached_eas_detected is None:
# We need to calculate one or both, check if we should
if cache_only:
continue
duration = time.time() - time_start
if 0 < time_limit < duration:
logger.debug(
Expand All @@ -278,17 +278,17 @@ def media_errors_generator(media_paths: list[str], media_roots: list[str],
cache_only = True
continue

if cached_error_count is not None:
error_count = int(cached_error_count)
else:
error_count = len(tools.ffmpeg.check_output(
['-y', '-v', 'error', '-i', filepath, '-c:v', 'vnull', '-c:a', 'anull', '-f', 'null',
'/dev/null'],
stderr=subprocess.STDOUT, text=True).splitlines())
config.set_file_config_option(filepath, 'error', 'count', str(error_count))

cached_eas_detected = config.get_file_config_option(filepath, 'error', 'eas')
if cached_eas_detected is not None:
eas_detected = cached_eas_detected.lower() == "true"
elif cache_only:
continue
else:
eas_detected = detect_eas_tones(filepath)
config.set_file_config_option(filepath, 'error', 'eas', str(eas_detected))
Expand Down

0 comments on commit c9ad26b

Please sign in to comment.