From c384bb91c4dd14419d123abeaf43b3383632faad Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Thu, 14 May 2020 22:34:27 -0400 Subject: [PATCH] added checkbox to ensure width and height are divisible by 2 --- src/video2x.yaml | 3 ++- src/video2x_gui.py | 14 ++++++++++++++ src/video2x_gui.pyproject.user | 2 +- src/video2x_gui.ui | 10 ++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/video2x.yaml b/src/video2x.yaml index 2c5bf13..a88ecae 100644 --- a/src/video2x.yaml +++ b/src/video2x.yaml @@ -1,7 +1,7 @@ # Name: Video2X Configuration File # Creator: K4YT3X # Date Created: October 23, 2018 -# Last Modified: May 12, 2020 +# Last Modified: May 14, 2020 # Values here are the default values. Change the value here to # save the default value permanently. # Items commented out are parameters irrelevant to this context @@ -122,6 +122,7 @@ ffmpeg: '-pix_fmt': 'yuv444p10le' # overwrite default pixel format '-crf': 17 # H.264 Constant Rate Factor '-b:v': null # target average bitrate + '-vf': 'pad=ceil(iw/2)*2:ceil(ih/2)*2' # ensure output is divisible by 2, recommended for libx264 # Step 3: Streams Migration # migrate audio and subtitle streams from original # video into the upscaled video diff --git a/src/video2x_gui.py b/src/video2x_gui.py index 814aeeb..520a623 100755 --- a/src/video2x_gui.py +++ b/src/video2x_gui.py @@ -362,6 +362,7 @@ class Video2XMainWindow(QMainWindow): self.ffmpeg_assemble_video_output_options_pixel_format_line_edit = self.findChild(QLineEdit, 'ffmpegAssembleVideoOutputOptionsPixelFormatLineEdit') self.ffmpeg_assemble_video_output_options_crf_spin_box = self.findChild(QSpinBox, 'ffmpegAssembleVideoOutputOptionsCrfSpinBox') self.ffmpeg_assemble_video_output_options_bitrate_line_edit = self.findChild(QLineEdit, 'ffmpegAssembleVideoOutputOptionsBitrateLineEdit') + self.ffmpeg_assemble_video_output_options_ensure_divisible_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoOutputOptionsEnsureDivisibleCheckBox') self.ffmpeg_assemble_video_hardware_acceleration_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoHardwareAccelerationCheckBox') # migrate_streams @@ -649,6 +650,19 @@ class Video2XMainWindow(QMainWindow): self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text() else: self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = None + + if self.ffmpeg_assemble_video_output_options_ensure_divisible_check_box.isChecked(): + # if video filter is enabled and is not empty and is not equal to divisible by two filter + # append divisible by two filter to the end of existing filter + if ('-vf' in self.config['ffmpeg']['assemble_video']['output_options'] and + len(self.config['ffmpeg']['assemble_video']['output_options']['-vf']) > 0 and + self.config['ffmpeg']['assemble_video']['output_options']['-vf'] != 'pad=ceil(iw/2)*2:ceil(ih/2)*2'): + self.config['ffmpeg']['assemble_video']['output_options']['-vf'] += ',pad=ceil(iw/2)*2:ceil(ih/2)*2' + else: + self.config['ffmpeg']['assemble_video']['output_options']['-vf'] = 'pad=ceil(iw/2)*2:ceil(ih/2)*2' + else: + self.config['ffmpeg']['assemble_video']['output_options'].pop('-vf', None) + if self.ffmpeg_assemble_video_hardware_acceleration_check_box.isChecked(): self.config['ffmpeg']['assemble_video']['-hwaccel'] = 'auto' else: diff --git a/src/video2x_gui.pyproject.user b/src/video2x_gui.pyproject.user index 25ddc8c..90555ba 100644 --- a/src/video2x_gui.pyproject.user +++ b/src/video2x_gui.pyproject.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/src/video2x_gui.ui b/src/video2x_gui.ui index ebaa81d..090bd14 100644 --- a/src/video2x_gui.ui +++ b/src/video2x_gui.ui @@ -1930,6 +1930,16 @@ + + + + Ensure output width and height are divisible by 2 + + + true + + +