From b72fb6d6f0fd22df74a33e7af7f57e7d55bba55e Mon Sep 17 00:00:00 2001 From: n9Mtq4 Date: Mon, 21 Sep 2020 21:19:25 -0400 Subject: [PATCH] Add live updating progress bar for svt-av1 --- Av1an/bar.py | 5 +++-- Encoders/svtav1.py | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Av1an/bar.py b/Av1an/bar.py index ba05a8f..1ad91d5 100755 --- a/Av1an/bar.py +++ b/Av1an/bar.py @@ -98,11 +98,12 @@ def tqdm_bar(a: Args, c: Chunk, encoder, counter, frame_probe_source, passes, cu enc = ENCODERS[encoder] pipe = enc.make_pipes(a, c, passes, current_pass, c.output) - if encoder in ('aom', 'vpx', 'rav1e', 'x265', 'x264', 'vvc'): + if encoder in ('aom', 'vpx', 'rav1e', 'x265', 'x264', 'vvc', 'svt_av1'): process_encoding_pipe(pipe, encoder, counter) - if encoder in ('svt_av1', 'svt_vp9'): + if encoder in ('svt_vp9'): # SVT-AV1 developer: SVT-AV1 is special in the way it outputs to console + # SVT-AV1 got a new output mode, but SVT-VP9 is still special process_pipe(pipe) counter.update(frame_probe_source // passes) diff --git a/Encoders/svtav1.py b/Encoders/svtav1.py index a6c66ac..1a334ee 100644 --- a/Encoders/svtav1.py +++ b/Encoders/svtav1.py @@ -1,10 +1,11 @@ import os +import re from Av1an.arg_parse import Args from Chunks.chunk import Chunk from Av1an.commandtypes import MPCommands, CommandPair, Command from Encoders.encoder import Encoder -from Av1an.utils import list_index_of_regex +from Av1an.utils import list_index_of_regex, terminate class SvtAv1(Encoder): @@ -23,7 +24,7 @@ class SvtAv1(Encoder): return [ CommandPair( Encoder.compose_ffmpeg_pipe(a), - ['SvtAv1EncApp', '-i', 'stdin', *a.video_params, '-b', output, '-'] + ['SvtAv1EncApp', '-i', 'stdin', '--progress', '2', *a.video_params, '-b', output, '-'] ) ] @@ -31,13 +32,13 @@ class SvtAv1(Encoder): return [ CommandPair( Encoder.compose_ffmpeg_pipe(a), - ['SvtAv1EncApp', '-i', 'stdin', '--irefresh-type 2', *a.video_params, '-output-stat-file', f'{c.fpf}.stat', '-b', os.devnull, - '-'] + ['SvtAv1EncApp', '-i', 'stdin', '--progress', '2', '--irefresh-type', '2', *a.video_params, + '-output-stat-file', f'{c.fpf}.stat', '-b', os.devnull, '-'] ), CommandPair( Encoder.compose_ffmpeg_pipe(a), - ['SvtAv1EncApp', '-i', 'stdin', '--irefresh-type 2', *a.video_params, '-input-stat-file', f'{c.fpf}.stat', '-b', output, - '-'] + ['SvtAv1EncApp', '-i', 'stdin', '--progress', '2', '--irefresh-type', '2', *a.video_params, + '-input-stat-file', f'{c.fpf}.stat', '-b', output, '-'] ) ] @@ -60,4 +61,7 @@ class SvtAv1(Encoder): :param line: one line of text output from the encoder :return: match object from re.search matching the number of encoded frames""" - pass # todo: SVT encoders are special in the way they output to console + if 'error' in line.lower(): + print('\n\nERROR IN ENCODING PROCESS\n\n', line) + terminate() + return re.search(r"Encoding frame\s+(\d+)", line)