mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge pull request #1429 from pypeclub/bugfix/1324-hiero-missing-thumbnail-in-review
This commit is contained in:
commit
cbf518396b
4 changed files with 99 additions and 54 deletions
59
openpype/hosts/hiero/plugins/publish/extract_thumbnail.py
Normal file
59
openpype/hosts/hiero/plugins/publish/extract_thumbnail.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
import openpype.api
|
||||
|
||||
|
||||
class ExtractThumnail(openpype.api.Extractor):
|
||||
"""
|
||||
Extractor for track item's tumnails
|
||||
"""
|
||||
|
||||
label = "Extract Thumnail"
|
||||
order = pyblish.api.ExtractorOrder
|
||||
families = ["plate", "take"]
|
||||
hosts = ["hiero"]
|
||||
|
||||
def process(self, instance):
|
||||
# create representation data
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = []
|
||||
|
||||
staging_dir = self.staging_dir(instance)
|
||||
|
||||
self.create_thumbnail(staging_dir, instance)
|
||||
|
||||
def create_thumbnail(self, staging_dir, instance):
|
||||
track_item = instance.data["item"]
|
||||
track_item_name = track_item.name()
|
||||
|
||||
# frames
|
||||
duration = track_item.sourceDuration()
|
||||
frame_start = track_item.sourceIn()
|
||||
self.log.debug(
|
||||
"__ frame_start: `{}`, duration: `{}`".format(
|
||||
frame_start, duration))
|
||||
|
||||
# get thumbnail frame from the middle
|
||||
thumb_frame = int(frame_start + (duration / 2))
|
||||
|
||||
thumb_file = "{}thumbnail{}{}".format(
|
||||
track_item_name, thumb_frame, ".png")
|
||||
thumb_path = os.path.join(staging_dir, thumb_file)
|
||||
|
||||
thumbnail = track_item.thumbnail(thumb_frame).save(
|
||||
thumb_path,
|
||||
format='png'
|
||||
)
|
||||
self.log.debug(
|
||||
"__ thumb_path: `{}`, frame: `{}`".format(thumbnail, thumb_frame))
|
||||
|
||||
self.log.info("Thumnail was generated to: {}".format(thumb_path))
|
||||
thumb_representation = {
|
||||
'files': thumb_file,
|
||||
'stagingDir': staging_dir,
|
||||
'name': "thumbnail",
|
||||
'thumbnail': True,
|
||||
'ext': "png"
|
||||
}
|
||||
instance.data["representations"].append(
|
||||
thumb_representation)
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
import openpype.api
|
||||
from openpype.hosts import resolve
|
||||
|
||||
|
||||
class ExtractWorkfile(openpype.api.Extractor):
|
||||
"""
|
||||
Extractor export DRP workfile file representation
|
||||
"""
|
||||
|
||||
label = "Extract Workfile"
|
||||
order = pyblish.api.ExtractorOrder
|
||||
families = ["workfile"]
|
||||
hosts = ["resolve"]
|
||||
|
||||
def process(self, instance):
|
||||
# create representation data
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = []
|
||||
|
||||
name = instance.data["name"]
|
||||
project = instance.context.data["activeProject"]
|
||||
staging_dir = self.staging_dir(instance)
|
||||
|
||||
resolve_workfile_ext = ".drp"
|
||||
drp_file_name = name + resolve_workfile_ext
|
||||
drp_file_path = os.path.normpath(
|
||||
os.path.join(staging_dir, drp_file_name))
|
||||
|
||||
# write out the drp workfile
|
||||
resolve.get_project_manager().ExportProject(
|
||||
project.GetName(), drp_file_path)
|
||||
|
||||
# create drp workfile representation
|
||||
representation_drp = {
|
||||
'name': resolve_workfile_ext[1:],
|
||||
'ext': resolve_workfile_ext[1:],
|
||||
'files': drp_file_name,
|
||||
"stagingDir": staging_dir,
|
||||
}
|
||||
|
||||
instance.data["representations"].append(representation_drp)
|
||||
|
||||
# add sourcePath attribute to instance
|
||||
if not instance.data.get("sourcePath"):
|
||||
instance.data["sourcePath"] = drp_file_path
|
||||
|
||||
self.log.info("Added Resolve file representation: {}".format(
|
||||
representation_drp))
|
||||
|
|
@ -2,7 +2,7 @@ from pyblish import api
|
|||
import openpype.api as pype
|
||||
|
||||
|
||||
class VersionUpWorkfile(api.ContextPlugin):
|
||||
class IntegrateVersionUpWorkfile(api.ContextPlugin):
|
||||
"""Save as new workfile version"""
|
||||
|
||||
order = api.IntegratorOrder + 10.1
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
import os
|
||||
import pyblish.api
|
||||
import hiero.ui
|
||||
from openpype.hosts.hiero import api as phiero
|
||||
from avalon import api as avalon
|
||||
from pprint import pformat
|
||||
from openpype.hosts.hiero.otio import hiero_export
|
||||
|
||||
from Qt.QtGui import QPixmap
|
||||
import tempfile
|
||||
|
||||
class PrecollectWorkfile(pyblish.api.ContextPlugin):
|
||||
"""Inject the current working file into context"""
|
||||
|
|
@ -23,12 +25,46 @@ class PrecollectWorkfile(pyblish.api.ContextPlugin):
|
|||
# adding otio timeline to context
|
||||
otio_timeline = hiero_export.create_otio_timeline()
|
||||
|
||||
# get workfile thumnail paths
|
||||
tmp_staging = tempfile.mkdtemp(prefix="pyblish_tmp_")
|
||||
thumbnail_name = "workfile_thumbnail.png"
|
||||
thumbnail_path = os.path.join(tmp_staging, thumbnail_name)
|
||||
|
||||
# search for all windows with name of actual sequence
|
||||
_windows = [w for w in hiero.ui.windowManager().windows()
|
||||
if active_timeline.name() in w.windowTitle()]
|
||||
|
||||
# export window to thumb path
|
||||
QPixmap.grabWidget(_windows[-1]).save(thumbnail_path, 'png')
|
||||
|
||||
# thumbnail
|
||||
thumb_representation = {
|
||||
'files': thumbnail_name,
|
||||
'stagingDir': tmp_staging,
|
||||
'name': "thumbnail",
|
||||
'thumbnail': True,
|
||||
'ext': "png"
|
||||
}
|
||||
|
||||
# get workfile paths
|
||||
curent_file = project.path()
|
||||
staging_dir, base_name = os.path.split(curent_file)
|
||||
|
||||
# creating workfile representation
|
||||
workfile_representation = {
|
||||
'name': 'hrox',
|
||||
'ext': 'hrox',
|
||||
'files': base_name,
|
||||
"stagingDir": staging_dir,
|
||||
}
|
||||
|
||||
instance_data = {
|
||||
"name": "{}_{}".format(asset, subset),
|
||||
"asset": asset,
|
||||
"subset": "{}{}".format(asset, subset.capitalize()),
|
||||
"item": project,
|
||||
"family": "workfile"
|
||||
"family": "workfile",
|
||||
"representations": [workfile_representation, thumb_representation]
|
||||
}
|
||||
|
||||
# create instance with workfile
|
||||
|
|
@ -38,7 +74,7 @@ class PrecollectWorkfile(pyblish.api.ContextPlugin):
|
|||
context_data = {
|
||||
"activeProject": project,
|
||||
"otioTimeline": otio_timeline,
|
||||
"currentFile": project.path(),
|
||||
"currentFile": curent_file,
|
||||
"fps": fps,
|
||||
}
|
||||
context.data.update(context_data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue