better error printing

This commit is contained in:
Zen 2020-06-21 22:02:36 +03:00
parent fc93f71cbe
commit cee6eeb1e9
2 changed files with 20 additions and 3 deletions

View file

@ -3,7 +3,7 @@ from subprocess import PIPE, STDOUT
import re import re
from multiprocessing.managers import BaseManager from multiprocessing.managers import BaseManager
from tqdm import tqdm from tqdm import tqdm
from utils.utils import terminate
# Stuff for updating encoded progress in real-time # Stuff for updating encoded progress in real-time
class MyManager(BaseManager): class MyManager(BaseManager):
@ -46,12 +46,22 @@ def tqdm_bar(i, encoder, counter, frame_probe_source, passes):
line = pipe.stdout.readline().strip() line = pipe.stdout.readline().strip()
if len(line) == 0 and pipe.poll() is not None: if len(line) == 0 and pipe.poll() is not None:
break break
if len(line) == 0:
continue
if encoder in ('aom', 'vpx', 'rav1e'): if encoder in ('aom', 'vpx', 'rav1e'):
match = None match = None
if encoder in ('aom', 'vpx'): 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: if 'Pass 2/2' in line or 'Pass 1/1' in line:
match = re.search(r"frame.*?\/([^ ]+?) ", line) match = re.search(r"frame.*?\/([^ ]+?) ", line)
elif encoder == 'rav1e': elif encoder == 'rav1e':
if 'error' in line.lower():
print('\n\nERROR IN ENCODING PROCESS\n\n', line)
terminate()
match = re.search(r"encoded.*? ([^ ]+?) ", line) match = re.search(r"encoded.*? ([^ ]+?) ", line)
if match: if match:

View file

@ -8,6 +8,7 @@ import numpy as np
from math import isnan from math import isnan
from scipy import interpolate from scipy import interpolate
import matplotlib import matplotlib
from utils.utils import terminate
def read_vmaf_xml(file, percentile): 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 vmaf calculation both source and encoded segment scaled to 1080
# for proper vmaf calculation # for proper vmaf calculation
fl = source.with_name(encoded.stem).with_suffix('.xml').as_posix() 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'-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'[1:v]scale=1920:1080:flags=spline:force_original_aspect_ratio=decrease[scaled2];' \
f'[scaled2][scaled1]libvmaf=log_path={fl}{mod}" -f null - ' 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: if return_file:
return fl return fl