mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Fix extract render
- Harmony always returns error code. Ignoring return code. - Fix missing thumbnail.
This commit is contained in:
parent
2e5a3922bc
commit
01bef1f2a9
1 changed files with 44 additions and 8 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import os
|
||||
import tempfile
|
||||
import subprocess
|
||||
|
||||
import pyblish.api
|
||||
from avalon import harmony
|
||||
import pype.lib
|
||||
|
||||
import clique
|
||||
|
||||
|
|
@ -37,7 +37,6 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
{"function": func, "args": [instance[0]]}
|
||||
)["result"]
|
||||
application_path = result[0]
|
||||
project_path = result[1]
|
||||
scene_path = os.path.join(result[1], result[2] + ".xstage")
|
||||
frame_rate = result[3]
|
||||
frame_start = result[4]
|
||||
|
|
@ -59,9 +58,16 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
)
|
||||
harmony.save_scene()
|
||||
|
||||
# Execute rendering.
|
||||
output = pype.lib._subprocess([application_path, "-batch", scene_path])
|
||||
self.log.info(output)
|
||||
# Execute rendering. Ignoring error cause Harmony returns error code
|
||||
# always.
|
||||
proc = subprocess.Popen(
|
||||
[application_path, "-batch", scene_path],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
stdin=subprocess.PIPE
|
||||
)
|
||||
output, error = proc.communicate()
|
||||
self.log.info(output.decode("utf-8"))
|
||||
|
||||
# Collect rendered files.
|
||||
files = os.listdir(path)
|
||||
|
|
@ -77,6 +83,30 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
)
|
||||
)
|
||||
|
||||
# Generate thumbnail.
|
||||
thumbnail_path = os.path.join(path, "thumbnail.png")
|
||||
args = [
|
||||
"ffmpeg", "-y",
|
||||
"-i", os.path.join(path, list(collections[0])[0]),
|
||||
"-vf", "scale=300:-1",
|
||||
"-vframes", "1",
|
||||
thumbnail_path
|
||||
]
|
||||
process = subprocess.Popen(
|
||||
args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
stdin=subprocess.PIPE
|
||||
)
|
||||
|
||||
output = process.communicate()[0]
|
||||
|
||||
if process.returncode != 0:
|
||||
raise ValueError(output.decode("utf-8"))
|
||||
|
||||
self.log.debug(output.decode("utf-8"))
|
||||
|
||||
# Generate representations.
|
||||
extension = os.path.splitext(list(collections[0])[0])[-1][1:]
|
||||
representation = {
|
||||
"name": extension,
|
||||
|
|
@ -89,12 +119,18 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
"preview": True,
|
||||
"tags": ["review"]
|
||||
}
|
||||
instance.data["representations"] = [representation]
|
||||
self.log.info(frame_rate)
|
||||
thumbnail = {
|
||||
"name": "thumbnail",
|
||||
"ext": "png",
|
||||
"files": os.path.basename(thumbnail_path),
|
||||
"stagingDir": path,
|
||||
"tags": ["thumbnail"]
|
||||
}
|
||||
instance.data["representations"] = [representation, thumbnail]
|
||||
|
||||
# Required for extract_review plugin (L222 onwards).
|
||||
instance.data["frameStart"] = frame_start
|
||||
instance.data["frameEnd"] = frame_end
|
||||
instance.data["fps"] = frame_rate
|
||||
|
||||
self.log.info("Extracted {instance} to {path}".format(**locals()))
|
||||
self.log.info(f"Extracted {instance} to {path}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue