mirror of
https://github.com/k4yt3x/video2x.git
synced 2024-12-29 16:09:10 +00:00
fixing issue #249 by @GitGerby
This commit is contained in:
parent
1be2c1ead7
commit
0c3c136458
@ -4,7 +4,7 @@
|
||||
Name: Video2X Upscaler
|
||||
Author: K4YT3X
|
||||
Date Created: December 10, 2018
|
||||
Last Modified: May 11, 2020
|
||||
Last Modified: May 12, 2020
|
||||
|
||||
Description: This file contains the Upscaler class. Each
|
||||
instance of the Upscaler class is an upscaler on an image or
|
||||
@ -584,24 +584,33 @@ class Upscaler:
|
||||
# if failed to copy streams
|
||||
# use file with only video stream
|
||||
except subprocess.CalledProcessError:
|
||||
traceback.print_exc()
|
||||
Avalon.error(_('Failed to migrate streams'))
|
||||
Avalon.warning(_('Trying to output video without additional streams'))
|
||||
|
||||
if input_file_mime_type == 'image/gif':
|
||||
(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name).replace(output_path)
|
||||
# copy will overwrite destination content if exists
|
||||
shutil.copy(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name, output_path)
|
||||
|
||||
else:
|
||||
# construct output file path
|
||||
output_video_path = output_path.parent / f'{output_path.stem}{self.ffmpeg_object.intermediate_file_name.suffix}'
|
||||
output_file_name = f'{output_path.stem}{self.ffmpeg_object.intermediate_file_name.suffix}'
|
||||
output_video_path = output_path.parent / output_file_name
|
||||
|
||||
# if output file already exists, cancel
|
||||
# if output file already exists
|
||||
# create temporary directory in output folder
|
||||
# temporary directories generated by tempfile are guaranteed to be unique
|
||||
# and won't conflict with other files
|
||||
if output_video_path.exists():
|
||||
Avalon.error(_('Output video file exists, aborting'))
|
||||
Avalon.error(_('Output video file exists'))
|
||||
|
||||
# otherwise, rename intermediate file to the output file
|
||||
else:
|
||||
Avalon.info(_('Writing intermediate file to: {}').format(output_video_path.absolute()))
|
||||
(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name).rename(output_video_path)
|
||||
temporary_directory = pathlib.Path(tempfile.mkdtemp(dir=output_path.parent))
|
||||
output_video_path = temporary_directory / output_file_name
|
||||
Avalon.info(_('Created temporary directory to contain file'))
|
||||
|
||||
# copy file to new destination
|
||||
Avalon.info(_('Writing intermediate file to: {}').format(output_video_path.absolute()))
|
||||
shutil.copy(self.upscaled_frames / self.ffmpeg_object.intermediate_file_name, output_video_path)
|
||||
|
||||
# increment total number of files processed
|
||||
self.cleanup_temp_directories()
|
||||
|
Loading…
Reference in New Issue
Block a user