mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
* Add pubsub to render_queue and base_worker * Refactor: Convert ZeroconfServer to Singleton with Class Methods * New API for subjob servers to notify parent job servers of status changes * Refactor: Move all subjob related methods to distributed_job_manager.py * Rewrite for wait_for_subjobs * Fix: DistributedJobManager.find_available_servers() takes 1 positional argument but 3 were given * DistributedJobManager should now notify / be notified abotu background job changes * Fix the make_ready api. Change children keyname to be id@hostname so it can be unique * Fixes * Image sequence to movie needs to find the actual start frame * Fix: subjob_status_change did not return a valid response * Fix client renderer selection * Small fix for subjob status checking * Fix issue with divide_frames_equally * Fix issue where downloads were not occurring * Fix issue where old status was being reported * Add docstrings and code cleanup
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
import logging
|
|
import os
|
|
import socket
|
|
import subprocess
|
|
import threading
|
|
|
|
import psutil
|
|
|
|
from lib.server.server_proxy import RenderServerProxy
|
|
from lib.utilities.ffmpeg_helper import generate_thumbnail, save_first_frame
|
|
|
|
logger = logging.getLogger()
|
|
|
|
|
|
def generate_thumbnail_for_job(job, thumb_video_path, thumb_image_path, max_width=320):
|
|
|
|
# Simple thread to generate thumbs in background
|
|
def generate_thumb_thread(source):
|
|
in_progress_path = thumb_video_path + '_IN-PROGRESS'
|
|
subprocess.run(['touch', in_progress_path])
|
|
try:
|
|
logger.debug(f"Generating video thumbnail for {source}")
|
|
generate_thumbnail(source_path=source, dest_path=thumb_video_path, max_width=max_width)
|
|
except subprocess.CalledProcessError as e:
|
|
logger.error(f"Error generating video thumbnail for {source}: {e}")
|
|
|
|
try:
|
|
os.remove(in_progress_path)
|
|
except FileNotFoundError:
|
|
pass
|
|
|
|
# Determine best source file to use for thumbs
|
|
source_files = job.file_list() or [job.input_path]
|
|
if source_files:
|
|
video_formats = ['.mp4', '.mov', '.avi', '.mpg', '.mpeg', '.mxf', '.m4v', 'mkv']
|
|
image_formats = ['.jpg', '.png', '.exr']
|
|
|
|
image_files = [f for f in source_files if os.path.splitext(f)[-1].lower() in image_formats]
|
|
video_files = [f for f in source_files if os.path.splitext(f)[-1].lower() in video_formats]
|
|
|
|
if (video_files or image_files) and not os.path.exists(thumb_image_path):
|
|
try:
|
|
path_of_source = image_files[0] if image_files else video_files[0]
|
|
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:
|
|
logger.error(f"Exception saving first frame: {e}")
|
|
|
|
if video_files and not os.path.exists(thumb_video_path):
|
|
x = threading.Thread(target=generate_thumb_thread, args=(video_files[0],))
|
|
x.start()
|