added checkbox to ensure width and height are divisible by 2

This commit is contained in:
k4yt3x 2020-05-14 22:34:27 -04:00
parent 0882f44e1f
commit c384bb91c4
4 changed files with 27 additions and 2 deletions

View File

@ -1,7 +1,7 @@
# Name: Video2X Configuration File # Name: Video2X Configuration File
# Creator: K4YT3X # Creator: K4YT3X
# Date Created: October 23, 2018 # 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 # Values here are the default values. Change the value here to
# save the default value permanently. # save the default value permanently.
# Items commented out are parameters irrelevant to this context # Items commented out are parameters irrelevant to this context
@ -122,6 +122,7 @@ ffmpeg:
'-pix_fmt': 'yuv444p10le' # overwrite default pixel format '-pix_fmt': 'yuv444p10le' # overwrite default pixel format
'-crf': 17 # H.264 Constant Rate Factor '-crf': 17 # H.264 Constant Rate Factor
'-b:v': null # target average bitrate '-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 # Step 3: Streams Migration
# migrate audio and subtitle streams from original # migrate audio and subtitle streams from original
# video into the upscaled video # video into the upscaled video

View File

@ -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_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_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_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') self.ffmpeg_assemble_video_hardware_acceleration_check_box = self.findChild(QCheckBox, 'ffmpegAssembleVideoHardwareAccelerationCheckBox')
# migrate_streams # 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() self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = self.ffmpeg_assemble_video_output_options_bitrate_line_edit.text()
else: else:
self.config['ffmpeg']['assemble_video']['output_options']['-b:v'] = None 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(): if self.ffmpeg_assemble_video_hardware_acceleration_check_box.isChecked():
self.config['ffmpeg']['assemble_video']['-hwaccel'] = 'auto' self.config['ffmpeg']['assemble_video']['-hwaccel'] = 'auto'
else: else:

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.12.0, 2020-05-14T20:16:43. --> <!-- Written by QtCreator 4.12.0, 2020-05-14T22:33:50. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -1930,6 +1930,16 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="ffmpegAssembleVideoOutputOptionsEnsureDivisibleCheckBox">
<property name="text">
<string>Ensure output width and height are divisible by 2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>