mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
get the frameStart and frameEnd from the representation data
This commit is contained in:
parent
87ddaa1756
commit
1bce2eae70
1 changed files with 39 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import pyblish.api
|
||||
import clique
|
||||
|
||||
|
||||
class CollectFrameRangeData(pyblish.api.InstancePlugin):
|
||||
|
|
@ -11,15 +12,50 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin):
|
|||
"vdbcache", "online",
|
||||
"render"]
|
||||
hosts = ["traypublisher"]
|
||||
img_extensions = ["exr", "dpx", "jpg", "jpeg", "png", "tiff", "tga",
|
||||
"gif", "svg"]
|
||||
video_extensions = ["avi", "mov", "mp4"]
|
||||
|
||||
def process(self, instance):
|
||||
repres = instance.data.get("representations")
|
||||
asset_data = None
|
||||
asset_doc = instance.data.get("assetEntity")
|
||||
if not asset_doc:
|
||||
self.log.debug("Instance has no asset entity set."
|
||||
" Skipping collecting frame range data.")
|
||||
" Skipping collecting frame range data.")
|
||||
return
|
||||
if repres:
|
||||
first_repre = repres[0]
|
||||
ext = first_repre["ext"].replace(".", "")
|
||||
if not ext or ext.lower() not in self.img_extensions:
|
||||
self.log.warning(f"Cannot find file extension "
|
||||
" in representation data")
|
||||
return
|
||||
if ext in self.video_extensions:
|
||||
self.log.info("Collecting frame range data"
|
||||
" not supported for video extensions")
|
||||
return
|
||||
|
||||
files = first_repre["files"]
|
||||
repres_file = clique.assemble(
|
||||
files, minimum_items=1)[0][0]
|
||||
repres_frames = [frames for frames in repres_file.indexes]
|
||||
last_frame = len(repres_frames) - 1
|
||||
entity_data = asset_doc["data"]
|
||||
asset_data = {
|
||||
"fps": entity_data["fps"],
|
||||
"frameStart": repres_frames[0],
|
||||
"frameEnd": repres_frames[last_frame],
|
||||
"handleStart": entity_data["handleStart"],
|
||||
"handleEnd": entity_data["handleEnd"]
|
||||
}
|
||||
|
||||
else:
|
||||
self.log.info("No representation data.. "
|
||||
"\nUse Asset Entity data instead")
|
||||
|
||||
asset_data = asset_doc["data"]
|
||||
|
||||
asset_data = asset_doc["data"]
|
||||
key_sets = []
|
||||
for key in (
|
||||
"fps",
|
||||
|
|
@ -32,5 +68,5 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin):
|
|||
instance.data[key] = asset_data[key]
|
||||
key_sets.append(key)
|
||||
|
||||
self.log.debug(f"Anatomy frame range data {key_sets} "
|
||||
self.log.debug(f"Frame range data {key_sets} "
|
||||
"has been collected from asset entity.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue