mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
Fix failing thumbnail generation
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import ffmpeg # todo: remove all references to ffmpeg library and instead use direct subprocesses
|
import ffmpeg # todo: remove all references to ffmpeg library and instead use direct subprocesses
|
||||||
from ..engines.ffmpeg_engine import FFMPEG
|
from lib.engines.ffmpeg_engine import FFMPEG
|
||||||
|
|
||||||
|
|
||||||
def file_info(path):
|
def file_info(path):
|
||||||
|
|||||||
@@ -30,25 +30,22 @@ def generate_thumbnail_for_job(job, thumb_video_path, thumb_image_path, max_widt
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Determine best source file to use for thumbs
|
# Determine best source file to use for thumbs
|
||||||
if job.status == RenderStatus.COMPLETED: # use finished file for thumb
|
source_files = job.file_list() or [job.input_path]
|
||||||
source_path = job.file_list()
|
if source_files:
|
||||||
else:
|
|
||||||
source_path = [job.input_path] # use source if nothing else
|
|
||||||
|
|
||||||
if source_path:
|
|
||||||
video_formats = ['.mp4', '.mov', '.avi', '.mpg', '.mpeg', '.mxf', '.m4v', 'mkv']
|
video_formats = ['.mp4', '.mov', '.avi', '.mpg', '.mpeg', '.mxf', '.m4v', 'mkv']
|
||||||
image_formats = ['.jpg', '.png', '.exr']
|
image_formats = ['.jpg', '.png', '.exr']
|
||||||
|
|
||||||
is_image_file = any(ele in source_path[0] for ele in image_formats)
|
image_files = [f for f in source_files if os.path.splitext(f)[-1].lower() in image_formats]
|
||||||
is_video_file = any(ele in source_path[0] for ele in video_formats)
|
video_files = [f for f in source_files if os.path.splitext(f)[-1].lower() in video_formats]
|
||||||
|
|
||||||
if (is_image_file or is_video_file) and not os.path.exists(thumb_image_path):
|
if (video_files or image_files) and not os.path.exists(thumb_image_path):
|
||||||
try:
|
try:
|
||||||
logger.debug(f"Generating image thumbnail for {source_path[0]}")
|
path_of_source = image_files[0] if image_files else video_files[0]
|
||||||
save_first_frame(source_path=source_path[0], dest_path=thumb_image_path, max_width=max_width)
|
logger.debug(f"Generating image thumbnail for {path_of_source}")
|
||||||
|
save_first_frame(source_path=path_of_source, dest_path=thumb_image_path, max_width=max_width)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Exception saving first frame: {e}")
|
logger.error(f"Exception saving first frame: {e}")
|
||||||
|
|
||||||
if is_video_file and not os.path.exists(thumb_video_path):
|
if video_files and not os.path.exists(thumb_video_path):
|
||||||
x = threading.Thread(target=generate_thumb_thread, args=(source_path[0],))
|
x = threading.Thread(target=generate_thumb_thread, args=(video_files[0],))
|
||||||
x.start()
|
x.start()
|
||||||
|
|||||||
Reference in New Issue
Block a user