From 969cfe5c0d0a0f475e6a2c49136211111bd7af41 Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Sun, 11 Aug 2019 23:57:10 -0400 Subject: [PATCH] fixing issue #134 --- bin/ffmpeg.py | 25 ++++++++++++++----------- bin/video2x.json | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bin/ffmpeg.py b/bin/ffmpeg.py index 3bd6f91..14df385 100644 --- a/bin/ffmpeg.py +++ b/bin/ffmpeg.py @@ -119,6 +119,8 @@ class Ffmpeg: self.ffmpeg_binary ] + execute.extend(self._read_configuration(phase='video_to_frames')) + execute.extend([ '-i', input_video @@ -130,8 +132,6 @@ class Ffmpeg: extracted_frames / f'extracted_%0d.{self.image_format}' ]) - execute.extend(self._read_configuration(phase='video_to_frames')) - self._execute(execute) def convert_video(self, framerate, resolution, upscaled_frames): @@ -152,6 +152,9 @@ class Ffmpeg: resolution ] + # read other options + execute.extend(self._read_configuration(phase='frames_to_video')) + # read FFmpeg input options execute.extend(self._read_configuration(phase='frames_to_video', section='input_options')) @@ -173,9 +176,6 @@ class Ffmpeg: # read FFmpeg output options execute.extend(self._read_configuration(phase='frames_to_video', section='output_options')) - # read other options - execute.extend(self._read_configuration(phase='frames_to_video')) - # specify output file location execute.extend([ upscaled_frames / 'no_audio.mp4' @@ -192,12 +192,17 @@ class Ffmpeg: upscaled_frames {string} -- directory containing upscaled frames """ execute = [ - self.ffmpeg_binary, + self.ffmpeg_binary + ] + + execute.extend(self._read_configuration(phase='migrating_tracks')) + + execute.extend([ '-i', upscaled_frames / 'no_audio.mp4', '-i', input_video - ] + ]) execute.extend(self._read_configuration(phase='migrating_tracks', section='output_options')) @@ -205,8 +210,6 @@ class Ffmpeg: output_video ]) - execute.extend(self._read_configuration(phase='migrating_tracks')) - self._execute(execute) def _read_configuration(self, phase, section=None): @@ -277,9 +280,9 @@ class Ffmpeg: Returns: int -- execution return code """ - Avalon.debug_info(f'Executing: {execute}') - # turn all list elements into string to avoid errors execute = [str(e) for e in execute] + Avalon.debug_info(f'Executing: {execute}') + return subprocess.run(execute, shell=True, check=True).returncode diff --git a/bin/video2x.json b/bin/video2x.json index 19a3b5d..fab9097 100644 --- a/bin/video2x.json +++ b/bin/video2x.json @@ -73,6 +73,7 @@ "-b:v": null, "-pix_fmt": null }, + "-hwaccel": "auto", "-y": true }, "migrating_tracks": { @@ -85,6 +86,7 @@ "-c": "copy", "-pix_fmt": null }, + "-hwaccel": "auto", "-y": true } },