more features

This commit is contained in:
Vysyr committed 2026-10-31 23:43:04 +01:00
1 parent bd8edf5afb
commit 1530b74d04
10 files changed
+563 -39

No files matched your search

+11 -2
View File
@@ -26,6 +26,7 @@ class Renderer:
warmup: int = 8
mp4: bool = True
ffmpeg: str = None
audio: str = None
def __post_init__(self):
self._validate()
@@ -35,6 +36,8 @@ class Renderer:
value = getattr(self, name)
if type(value) is not int or value < minimum:
raise ValueError(f"{name} musi byc liczba calkowita >= {minimum}.")
if self.audio is not None and not self.mp4:
raise ValueError("audio wymaga mp4=True.")
@classmethod
def from_preset(cls, name="preview", **overrides):
@@ -84,7 +87,7 @@ def _on_finished(executor, success):
if state["mp4"]:
report("encoding")
result["video"] = str(encode(frames, state["fps"], ffmpeg=state["ffmpeg"],
expected_frames=state["frames"]))
expected_frames=state["frames"], audio=state["audio"]))
result["success"] = True
unreal.log("[Workshop] Gotowe: " + str(state["output"]))
except Exception as exc:
@@ -130,6 +133,12 @@ def _start(sequence, renderer, single_frame=None):
raise ValueError("Klatka poza zakresem sekwencji.")
mp4 = renderer.mp4 and single_frame is None
ffmpeg_path = executable("ffmpeg", renderer.ffmpeg) if mp4 else None
audio = None
if mp4 and renderer.audio is not None:
audio = Path(renderer.audio).expanduser()
audio = (audio if audio.is_absolute() else PROJECT / audio).resolve()
if not audio.is_file():
raise FileNotFoundError(audio)
subsystem = unreal.get_editor_subsystem(unreal.MoviePipelineQueueSubsystem)
if subsystem.is_rendering():
raise RuntimeError("Movie Render Queue jest zajete.")
@@ -171,7 +180,7 @@ def _start(sequence, renderer, single_frame=None):
executor.on_executor_finished_delegate.add_callable_unique(_on_finished)
_active = dict(executor=executor, queue=queue, output=output, errors=[], fps=sequence.fps,
frames=1 if single_frame is not None else sequence.frames,
mp4=mp4, ffmpeg=ffmpeg_path, ticks=2,
mp4=mp4, ffmpeg=ffmpeg_path, audio=audio, ticks=2,
settings=dict(width=width, height=height, samples=samples, warmup=warmup, fps=sequence.fps))
try:
_write_status({"state": "rendering", "output": str(output)})