mirror of
https://github.com/blw1138/Zordon.git
synced 2026-02-05 05:36:09 +00:00
* Initial refactor of add_job_window * Improved project naming and fixed Blender engine issue * Improve time representation in main window * Cleanup Blender job creation * Send resolution / fps data in job submission * More window improvements * EngineManager renaming and refactoring * FFMPEG path fixes for ffprobe * More backend refactoring / improvements * Performance improvements / API refactoring * Show current job count in add window UI before submission * Move some UI update code out of background thread * Move some main window UI update code out of background thread
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import re
|
|
|
|
from src.engines.core.base_worker import BaseRenderWorker
|
|
from src.engines.ffmpeg.ffmpeg_engine import FFMPEG
|
|
|
|
|
|
class FFMPEGRenderWorker(BaseRenderWorker):
|
|
|
|
engine = FFMPEG
|
|
|
|
def __init__(self, input_path, output_path, engine_path, args=None, parent=None, name=None):
|
|
super(FFMPEGRenderWorker, self).__init__(input_path=input_path, output_path=output_path,
|
|
engine_path=engine_path, args=args, parent=parent, name=name)
|
|
self.current_frame = -1
|
|
|
|
def generate_worker_subprocess(self):
|
|
|
|
cmd = [self.engine_path, '-y', '-stats', '-i', self.input_path]
|
|
|
|
# Resize frame
|
|
if self.args.get('resolution', None):
|
|
cmd.extend(['-vf', f"scale={self.args['resolution'][0]}:{self.args['resolution'][1]}"])
|
|
|
|
# Convert raw args from string if available
|
|
raw_args = self.args.get('raw', None)
|
|
if raw_args:
|
|
cmd.extend(raw_args.split(' '))
|
|
|
|
# Close with output path
|
|
cmd.extend(['-max_muxing_queue_size', '1024', self.output_path])
|
|
return cmd
|
|
|
|
def percent_complete(self):
|
|
return max(float(self.current_frame) / float(self.total_frames), 0.0)
|
|
|
|
def _parse_stdout(self, line):
|
|
pattern = re.compile(r'frame=\s*(?P<current_frame>\d+)\s*fps.*time=(?P<time_elapsed>\S+)')
|
|
found = pattern.search(line)
|
|
if found:
|
|
stats = found.groupdict()
|
|
self.current_frame = stats['current_frame']
|
|
time_elapsed = stats['time_elapsed']
|
|
elif "not found" in line:
|
|
self.log_error(line)
|