From f4bd47bb6ae1f020639d496e91b516c88271b4f5 Mon Sep 17 00:00:00 2001 From: Zen <46526140+master-of-zen@users.noreply.github.com> Date: Mon, 6 Jul 2020 20:08:23 +0300 Subject: [PATCH] Improved main queue, fixed pyscene don't showing with queue --- av1an.py | 20 ++++++++++---------- utils/pyscene.py | 4 ++-- utils/split.py | 4 ++-- utils/utils.py | 6 +----- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/av1an.py b/av1an.py index e1b8c9d..8db266a 100755 --- a/av1an.py +++ b/av1an.py @@ -282,7 +282,7 @@ class Av1an: # inherit video params from aom encode unless we are using a different encoder, then use defaults aom_keyframes_params = self.video_params if (self.encoder == 'aom') else AOM_KEYFRAMES_DEFAULT_PARAMS - framenums = split_routine(self.input, self.scenes, self.split_method, self.temp, self.min_scene_len, self.queue, self.threshold, self.ffmpeg_pipe, aom_keyframes_params) + framenums = split_routine(self.input, self.scenes, self.split_method, self.temp, self.min_scene_len, self.threshold, self.ffmpeg_pipe, aom_keyframes_params) if self.extra_split: framenums = extra_splits(self.input, framenums, self.extra_split) @@ -320,19 +320,19 @@ class Av1an: def main_queue(self): # Todo: Redo Queue tm = time.time() - self.queue, self.input = process_inputs(self.input) - if self.queue: - for file in self.queue: - tm = time.time() - self.input = file + self.queue = process_inputs(self.input) + + for file in self.queue: + tm = time.time() + self.input = file + + if len(self.queue) > 1: print(f'Encoding: {file}') self.output_file = None - self.video_encoding() - print(f'Finished: {round(time.time() - tm, 1)}s\n') - else: + self.video_encoding() - print(f'Finished: {round(time.time() - tm, 1)}s') + print(f'Finished: {round(time.time() - tm, 1)}s\n') def main_thread(self): """Main.""" diff --git a/utils/pyscene.py b/utils/pyscene.py index af3793e..79c8144 100755 --- a/utils/pyscene.py +++ b/utils/pyscene.py @@ -7,7 +7,7 @@ from scenedetect.video_manager import VideoManager from .logger import log -def pyscene(video, threshold, progress_show, min_scene_len): +def pyscene(video, threshold, min_scene_len): """ Running PySceneDetect detection on source video for segmenting. Optimal threshold settings 15-50 @@ -30,7 +30,7 @@ def pyscene(video, threshold, progress_show, min_scene_len): # Start video_manager. video_manager.start() - scene_manager.detect_scenes(frame_source=video_manager, show_progress= not progress_show) + scene_manager.detect_scenes(frame_source=video_manager, show_progress=True) # Obtain list of detected scenes. scene_list = scene_manager.get_scene_list(base_timecode) diff --git a/utils/split.py b/utils/split.py index a1b68d3..2ec3217 100755 --- a/utils/split.py +++ b/utils/split.py @@ -85,7 +85,7 @@ def extra_splits(video, frames: list, split_distance): return result -def split_routine(video, scenes, split_method, temp, min_scene_len, queue, threshold, ffmpeg_pipe, video_params): +def split_routine(video, scenes, split_method, temp, min_scene_len, threshold, ffmpeg_pipe, video_params): if scenes == '0': log('Skipping scene detection\n') @@ -106,7 +106,7 @@ def split_routine(video, scenes, split_method, temp, min_scene_len, queue, thres if split_method == 'pyscene': log(f'Starting scene detection Threshold: {threshold}, Min_scene_length: {min_scene_len}\n') try: - sc = pyscene(video, threshold, queue, min_scene_len) + sc = pyscene(video, threshold, min_scene_len) except Exception as e: log(f'Error in PySceneDetect: {e}\n') print(f'Error in PySceneDetect{e}\n') diff --git a/utils/utils.py b/utils/utils.py index 73707c7..3e2a00c 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -44,11 +44,7 @@ def process_inputs(inputs): print(f'File(s) do not exist: {", ".join([str(inputs[i]) for i in np.where(not valid)[0]])}') terminate() - if len(inputs) > 1: - return inputs, None - else: - return None, inputs[0] - + return inputs def get_keyframes(file: Path): """