diff --git a/utils/dynamic_progress_bar.py b/utils/dynamic_progress_bar.py index 8047d2d..1ca5d03 100644 --- a/utils/dynamic_progress_bar.py +++ b/utils/dynamic_progress_bar.py @@ -3,7 +3,7 @@ from subprocess import PIPE, STDOUT import re from multiprocessing.managers import BaseManager from tqdm import tqdm - +from utils.utils import terminate # Stuff for updating encoded progress in real-time class MyManager(BaseManager): @@ -46,12 +46,22 @@ def tqdm_bar(i, encoder, counter, frame_probe_source, passes): line = pipe.stdout.readline().strip() if len(line) == 0 and pipe.poll() is not None: break + + if len(line) == 0: + continue + if encoder in ('aom', 'vpx', 'rav1e'): match = None if encoder in ('aom', 'vpx'): + if 'fatal' in line.lower(): + print('\n\nERROR IN ENCODING PROCESS\n\n', line) + terminate() if 'Pass 2/2' in line or 'Pass 1/1' in line: match = re.search(r"frame.*?\/([^ ]+?) ", line) elif encoder == 'rav1e': + if 'error' in line.lower(): + print('\n\nERROR IN ENCODING PROCESS\n\n', line) + terminate() match = re.search(r"encoded.*? ([^ ]+?) ", line) if match: diff --git a/utils/vmaf.py b/utils/vmaf.py index 4ea722d..f360e22 100644 --- a/utils/vmaf.py +++ b/utils/vmaf.py @@ -8,6 +8,7 @@ import numpy as np from math import isnan from scipy import interpolate import matplotlib +from utils.utils import terminate def read_vmaf_xml(file, percentile): @@ -36,12 +37,18 @@ def call_vmaf( source: Path, encoded: Path, model=None, return_file=False): # For vmaf calculation both source and encoded segment scaled to 1080 # for proper vmaf calculation fl = source.with_name(encoded.stem).with_suffix('.xml').as_posix() - cmd = f'ffmpeg -hide_banner -r 60 -i {source.as_posix()} -r 60 -i {encoded.as_posix()} ' \ + cmd = f'ffmpeg -loglevel error -hide_banner -r 60 -i {source.as_posix()} -r 60 -i {encoded.as_posix()} ' \ f'-filter_complex "[0:v]scale=1920:1080:flags=spline:force_original_aspect_ratio=decrease[scaled1];' \ f'[1:v]scale=1920:1080:flags=spline:force_original_aspect_ratio=decrease[scaled2];' \ f'[scaled2][scaled1]libvmaf=log_path={fl}{mod}" -f null - ' - call = subprocess.run(cmd, shell=True, stdout=PIPE, stderr=STDOUT).stdout + c = subprocess.run(cmd, shell=True, stdout=PIPE, stderr=STDOUT) + call = c.stdout + # print(c.stdout.decode()) + if 'error' in call.decode().lower(): + print('\n\nERROR IN VMAF CALCULATION\n\n',call.decode()) + terminate() + if return_file: return fl