mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-01-30 23:58:11 +00:00
added output file name format string
This commit is contained in:
parent
06355441ea
commit
e44264bb6b
@ -4,7 +4,7 @@
|
|||||||
Name: Video2X Upscaler
|
Name: Video2X Upscaler
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: December 10, 2018
|
Date Created: December 10, 2018
|
||||||
Last Modified: June 8, 2020
|
Last Modified: June 29, 2020
|
||||||
|
|
||||||
Description: This file contains the Upscaler class. Each
|
Description: This file contains the Upscaler class. Each
|
||||||
instance of the Upscaler class is an upscaler on an image or
|
instance of the Upscaler class is an upscaler on an image or
|
||||||
@ -85,6 +85,7 @@ class Upscaler:
|
|||||||
processes: int = 1,
|
processes: int = 1,
|
||||||
video2x_cache_directory: pathlib.Path = pathlib.Path(tempfile.gettempdir()) / 'video2x',
|
video2x_cache_directory: pathlib.Path = pathlib.Path(tempfile.gettempdir()) / 'video2x',
|
||||||
extracted_frame_format: str = 'png',
|
extracted_frame_format: str = 'png',
|
||||||
|
output_file_name_format_string: str = '{original_file_name}_output{extension}',
|
||||||
image_output_extension: str = '.png',
|
image_output_extension: str = '.png',
|
||||||
video_output_extension: str = '.mp4',
|
video_output_extension: str = '.mp4',
|
||||||
preserve_frames: bool = False
|
preserve_frames: bool = False
|
||||||
@ -103,6 +104,7 @@ class Upscaler:
|
|||||||
self.processes = processes
|
self.processes = processes
|
||||||
self.video2x_cache_directory = video2x_cache_directory
|
self.video2x_cache_directory = video2x_cache_directory
|
||||||
self.extracted_frame_format = extracted_frame_format
|
self.extracted_frame_format = extracted_frame_format
|
||||||
|
self.output_file_name_format_string = output_file_name_format_string
|
||||||
self.image_output_extension = image_output_extension
|
self.image_output_extension = image_output_extension
|
||||||
self.video_output_extension = video_output_extension
|
self.video_output_extension = video_output_extension
|
||||||
self.preserve_frames = preserve_frames
|
self.preserve_frames = preserve_frames
|
||||||
@ -478,13 +480,13 @@ class Upscaler:
|
|||||||
# set default output file suffixes
|
# set default output file suffixes
|
||||||
# if image type is GIF, default output suffix is also .gif
|
# if image type is GIF, default output suffix is also .gif
|
||||||
if input_file_mime_type == 'image/gif':
|
if input_file_mime_type == 'image/gif':
|
||||||
output_path = self.output / (input_path.stem + '.gif')
|
output_path = self.output / self.output_file_name_format_string.format(original_file_name=input_path.stem, extension='.gif')
|
||||||
|
|
||||||
elif input_file_type == 'image':
|
elif input_file_type == 'image':
|
||||||
output_path = self.output / (input_path.stem + self.image_output_extension)
|
output_path = self.output / self.output_file_name_format_string.format(original_file_name=input_path.stem, extension=self.image_output_extension)
|
||||||
|
|
||||||
elif input_file_type == 'video':
|
elif input_file_type == 'video':
|
||||||
output_path = self.output / (input_path.stem + self.video_output_extension)
|
output_path = self.output / self.output_file_name_format_string.format(original_file_name=input_path.stem, extension=self.video_output_extension)
|
||||||
|
|
||||||
# if file is none of: image, image/gif, video
|
# if file is none of: image, image/gif, video
|
||||||
# skip to the next task
|
# skip to the next task
|
||||||
|
@ -13,7 +13,7 @@ __ __ _ _ ___ __ __
|
|||||||
Name: Video2X Controller
|
Name: Video2X Controller
|
||||||
Creator: K4YT3X
|
Creator: K4YT3X
|
||||||
Date Created: Feb 24, 2018
|
Date Created: Feb 24, 2018
|
||||||
Last Modified: June 8, 2020
|
Last Modified: June 29, 2020
|
||||||
|
|
||||||
Editor: BrianPetkovsek
|
Editor: BrianPetkovsek
|
||||||
Last Modified: June 17, 2019
|
Last Modified: June 17, 2019
|
||||||
@ -81,7 +81,7 @@ language = gettext.translation(DOMAIN, LOCALE_DIRECTORY, [default_locale], fallb
|
|||||||
language.install()
|
language.install()
|
||||||
_ = language.gettext
|
_ = language.gettext
|
||||||
|
|
||||||
CLI_VERSION = '4.1.1'
|
CLI_VERSION = '4.2.0'
|
||||||
|
|
||||||
LEGAL_INFO = _('''Video2X CLI Version: {}
|
LEGAL_INFO = _('''Video2X CLI Version: {}
|
||||||
Upscaler Version: {}
|
Upscaler Version: {}
|
||||||
@ -207,6 +207,7 @@ gifski_settings['gifski_path'] = os.path.expandvars(gifski_settings['gifski_path
|
|||||||
|
|
||||||
# load video2x settings
|
# load video2x settings
|
||||||
extracted_frame_format = config['video2x']['extracted_frame_format'].lower()
|
extracted_frame_format = config['video2x']['extracted_frame_format'].lower()
|
||||||
|
output_file_name_format_string = config['video2x']['output_file_name_format_string']
|
||||||
image_output_extension = config['video2x']['image_output_extension']
|
image_output_extension = config['video2x']['image_output_extension']
|
||||||
video_output_extension = config['video2x']['video_output_extension']
|
video_output_extension = config['video2x']['video_output_extension']
|
||||||
preserve_frames = config['video2x']['preserve_frames']
|
preserve_frames = config['video2x']['preserve_frames']
|
||||||
@ -250,6 +251,7 @@ try:
|
|||||||
processes=video2x_args.processes,
|
processes=video2x_args.processes,
|
||||||
video2x_cache_directory=video2x_cache_directory,
|
video2x_cache_directory=video2x_cache_directory,
|
||||||
extracted_frame_format=extracted_frame_format,
|
extracted_frame_format=extracted_frame_format,
|
||||||
|
output_file_name_format_string=output_file_name_format_string,
|
||||||
image_output_extension=image_output_extension,
|
image_output_extension=image_output_extension,
|
||||||
video_output_extension=video_output_extension,
|
video_output_extension=video_output_extension,
|
||||||
preserve_frames=preserve_frames
|
preserve_frames=preserve_frames
|
||||||
|
@ -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: June 7, 2020
|
# Last Modified: June 30, 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
|
||||||
@ -170,6 +170,7 @@ gifski:
|
|||||||
video2x:
|
video2x:
|
||||||
video2x_cache_directory: null # default: %TEMP%\video2x, directory where cache files are stored, will be deleted if preserve_frames is not set to true
|
video2x_cache_directory: null # default: %TEMP%\video2x, directory where cache files are stored, will be deleted if preserve_frames is not set to true
|
||||||
extracted_frame_format: png # png/jpg intermediate file format used for extracted frames during video processing
|
extracted_frame_format: png # png/jpg intermediate file format used for extracted frames during video processing
|
||||||
|
output_file_name_format_string: "{original_file_name}_output{extension}" # format string to use for generating output file names
|
||||||
image_output_extension: .png # image output extension during batch processing
|
image_output_extension: .png # image output extension during batch processing
|
||||||
video_output_extension: .mp4 # video output extension during batch processing
|
video_output_extension: .mp4 # video output extension during batch processing
|
||||||
preserve_frames: false # if set to true, the cache directory won't be cleaned upon task completion
|
preserve_frames: false # if set to true, the cache directory won't be cleaned upon task completion
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Creator: Video2X GUI
|
Creator: Video2X GUI
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: May 5, 2020
|
Date Created: May 5, 2020
|
||||||
Last Modified: June 8, 2020
|
Last Modified: June 30, 2020
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
@ -277,6 +277,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.driver_combo_box.currentTextChanged.connect(self.update_gui_for_driver)
|
self.driver_combo_box.currentTextChanged.connect(self.update_gui_for_driver)
|
||||||
self.processes_spin_box = self.findChild(QSpinBox, 'processesSpinBox')
|
self.processes_spin_box = self.findChild(QSpinBox, 'processesSpinBox')
|
||||||
self.scale_ratio_double_spin_box = self.findChild(QDoubleSpinBox, 'scaleRatioDoubleSpinBox')
|
self.scale_ratio_double_spin_box = self.findChild(QDoubleSpinBox, 'scaleRatioDoubleSpinBox')
|
||||||
|
self.output_file_name_format_string_line_edit = self.findChild(QLineEdit, 'outputFileNameFormatStringLineEdit')
|
||||||
self.image_output_extension_line_edit = self.findChild(QLineEdit, 'imageOutputExtensionLineEdit')
|
self.image_output_extension_line_edit = self.findChild(QLineEdit, 'imageOutputExtensionLineEdit')
|
||||||
self.video_output_extension_line_edit = self.findChild(QLineEdit, 'videoOutputExtensionLineEdit')
|
self.video_output_extension_line_edit = self.findChild(QLineEdit, 'videoOutputExtensionLineEdit')
|
||||||
self.preserve_frames_check_box = self.findChild(QCheckBox, 'preserveFramesCheckBox')
|
self.preserve_frames_check_box = self.findChild(QCheckBox, 'preserveFramesCheckBox')
|
||||||
@ -475,6 +476,7 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
self.config['video2x']['video2x_cache_directory'] = str((pathlib.Path(tempfile.gettempdir()) / 'video2x').absolute())
|
self.config['video2x']['video2x_cache_directory'] = str((pathlib.Path(tempfile.gettempdir()) / 'video2x').absolute())
|
||||||
self.cache_line_edit.setText(self.config['video2x']['video2x_cache_directory'])
|
self.cache_line_edit.setText(self.config['video2x']['video2x_cache_directory'])
|
||||||
|
|
||||||
|
self.output_file_name_format_string_line_edit.setText(self.config['video2x']['output_file_name_format_string'])
|
||||||
self.image_output_extension_line_edit.setText(self.config['video2x']['image_output_extension'])
|
self.image_output_extension_line_edit.setText(self.config['video2x']['image_output_extension'])
|
||||||
self.video_output_extension_line_edit.setText(self.config['video2x']['video_output_extension'])
|
self.video_output_extension_line_edit.setText(self.config['video2x']['video_output_extension'])
|
||||||
|
|
||||||
@ -943,10 +945,10 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
suffix = input_path.suffix
|
suffix = input_path.suffix
|
||||||
|
|
||||||
output_path = input_path.parent / f'{input_path.stem}_output{suffix}'
|
output_path = input_path.parent / self.output_file_name_format_string_line_edit.text().format(original_file_name=input_path.stem, extension=suffix)
|
||||||
|
|
||||||
elif input_path.is_dir():
|
elif input_path.is_dir():
|
||||||
output_path = input_path.parent / f'{input_path.stem}_output'
|
output_path = input_path.parent / self.output_file_name_format_string_line_edit.text().format(original_file_name=input_path.stem, extension='')
|
||||||
|
|
||||||
# try a new name with a different file ID
|
# try a new name with a different file ID
|
||||||
output_path_id = 0
|
output_path_id = 0
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>727</width>
|
<width>724</width>
|
||||||
<height>908</height>
|
<height>936</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="acceptDrops">
|
<property name="acceptDrops">
|
||||||
@ -142,11 +142,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="otherPathsSelectionGroupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Other Paths Selection</string>
|
<string>Output Selection</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_35">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="outputHorizontalLayout">
|
<layout class="QHBoxLayout" name="outputHorizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
@ -187,6 +187,45 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="outputFileNameFormatStringHorizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="outputFileNameFormatStringLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>63</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Output File Name Format String</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="outputFileNameFormatStringLineEdit">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Format string used to generate output file name(s).</p><p>For example, if the input is &quot;sample.mp4&quot;, and the format string is &quot;{original_file_name}_output{extension}&quot;, then the output file name will be &quot;sample_output.mp4&quot;.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>{original_file_name}_output{extension}</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="otherPathsSelectionGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Other Paths Selection</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="configHorizontalLayout">
|
<layout class="QHBoxLayout" name="configHorizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
@ -2835,7 +2874,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>727</width>
|
<width>724</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user