Merge branch 'hotfix/fixes_ind_edit_publish'

This commit is contained in:
Milan Kolar 2020-08-20 16:14:32 +02:00
commit 781f27a4d1
6 changed files with 134 additions and 38 deletions

View file

@ -30,7 +30,8 @@ class IntegrateFtrackInstance(pyblish.api.InstancePlugin):
'audio': 'audio',
'workfile': 'scene',
'animation': 'cache',
'image': 'img'
'image': 'img',
'reference': 'reference'
}
def process(self, instance):

View file

@ -193,6 +193,8 @@ class ExtractReview(pyblish.api.InstancePlugin):
# Force to pop these key if are in new repre
new_repre.pop("preview", None)
new_repre.pop("thumbnail", None)
if "clean_name" in new_repre.get("tags", []):
new_repre.pop("outputName")
# adding representation
self.log.debug(
@ -1528,6 +1530,8 @@ class ExtractReview(pyblish.api.InstancePlugin):
for repre in representations_new:
if "delete" in repre.get("tags", []):
representations_new.remove(repre)
if "clean_name" in repre.get("tags", []):
repre_new.pop("outputName")
instance.data.update({
"reviewToWidth": self.to_width,

View file

@ -351,7 +351,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
index_frame_start = None
if repre.get("frameStart"):
if repre.get("frameStart") is not None:
frame_start_padding = int(
anatomy.templates["render"].get(
"frame_padding",
@ -378,7 +378,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
dst_padding = src_padding_exp % i
if index_frame_start:
if index_frame_start is not None:
dst_padding_exp = "%0{}d".format(frame_start_padding)
dst_padding = dst_padding_exp % index_frame_start
index_frame_start += 1

View file

@ -18,15 +18,15 @@ class CollectClipInstances(pyblish.api.InstancePlugin):
"referenceMain": {
"family": "review",
"families": ["review", "ftrack"],
"ftrackFamily": "review",
# "ftrackFamily": "review",
"extension": ".mp4"
},
"audioMain": {
"family": "audio",
"families": ["ftrack"],
"ftrackFamily": "audio",
# "ftrackFamily": "audio",
"extension": ".wav",
"version": 1
# "version": 1
},
"shotMain": {
"family": "shot",

View file

@ -13,7 +13,6 @@ class ExtractShotData(pype.api.Extractor):
families = ["review", "audio"]
# presets
add_representation = None # ".jpeg"
def process(self, instance):
representation = instance.data.get("representations")
@ -68,7 +67,7 @@ class ExtractShotData(pype.api.Extractor):
self.log.info(f"Processing: {args}")
ffmpeg_args = " ".join(args)
output = pype.api.subprocess(ffmpeg_args)
output = pype.api.subprocess(ffmpeg_args, shell=True)
self.log.info(output)
repr = {
@ -90,34 +89,4 @@ class ExtractShotData(pype.api.Extractor):
instance.data["representations"].append(repr)
if self.add_representation:
# Generate jpegs.
clip_img_sequence = os.path.join(
staging_dir, instance.data["name"] + ".%04d.jpeg"
)
args = [
ffmpeg_path, "-i",
f"\"{clip_trimed_path}\"",
f"\"{clip_img_sequence}\""
]
self.log.info(f"Processing: {args}")
output = pype.lib._subprocess(args)
self.log.info(output)
# collect jpeg sequence if editorial data for publish
# are image sequence
collection = clique.Collection(
head=instance.data["name"] + ".", tail='.jpeg', padding=4
)
for f in os.listdir(staging_dir):
if collection.match(f):
collection.add(f)
instance.data["representations"].append({
"name": "jpeg",
"ext": "jpeg",
"files": list(collection),
"stagingDir": staging_dir
})
self.log.debug(f"Instance data: {pformat(instance.data)}")

View file

@ -0,0 +1,122 @@
import os
import tempfile
import subprocess
import pyblish.api
import pype.api
import pype.lib
class ExtractThumbnailSP(pyblish.api.InstancePlugin):
"""Extract jpeg thumbnail from component input from standalone publisher
Uses jpeg file from component if possible (when single or multiple jpegs
are loaded to component selected as thumbnail) otherwise extracts from
input file/s single jpeg to temp.
"""
label = "Extract Thumbnail SP"
hosts = ["standalonepublisher"]
order = pyblish.api.ExtractorOrder
# Presetable attribute
ffmpeg_args = None
def process(self, instance):
repres = instance.data.get('representations')
if not repres:
return
thumbnail_repre = None
for repre in repres:
if repre.get("thumbnail"):
thumbnail_repre = repre
break
if not thumbnail_repre:
return
files = thumbnail_repre.get("files")
if not files:
return
if isinstance(files, list):
files_len = len(files)
file = str(files[0])
else:
files_len = 1
file = files
is_jpeg = False
if file.endswith(".jpeg") or file.endswith(".jpg"):
is_jpeg = True
if is_jpeg and files_len == 1:
# skip if already is single jpeg file
return
elif is_jpeg:
# use first frame as thumbnail if is sequence of jpegs
full_thumbnail_path = file
self.log.info(
"For thumbnail is used file: {}".format(full_thumbnail_path)
)
else:
# Convert to jpeg if not yet
full_input_path = os.path.join(thumbnail_repre["stagingDir"], file)
self.log.info("input {}".format(full_input_path))
full_thumbnail_path = tempfile.mkstemp(suffix=".jpg")[1]
self.log.info("output {}".format(full_thumbnail_path))
ffmpeg_path = pype.lib.get_ffmpeg_tool_path("ffmpeg")
ffmpeg_args = self.ffmpeg_args or {}
jpeg_items = []
jpeg_items.append(ffmpeg_path)
# override file if already exists
jpeg_items.append("-y")
# add input filters from peresets
jpeg_items.extend(ffmpeg_args.get("input") or [])
# input file
jpeg_items.append("-i {}".format(full_input_path))
# extract only single file
jpeg_items.append("-vframes 1")
jpeg_items.extend(ffmpeg_args.get("output") or [])
# output file
jpeg_items.append(full_thumbnail_path)
subprocess_jpeg = " ".join(jpeg_items)
# run subprocess
self.log.debug("Executing: {}".format(subprocess_jpeg))
subprocess.Popen(
subprocess_jpeg,
stdout=subprocess.PIPE,
shell=True
)
# remove thumbnail key from origin repre
thumbnail_repre.pop("thumbnail")
filename = os.path.basename(full_thumbnail_path)
staging_dir = os.path.dirname(full_thumbnail_path)
# create new thumbnail representation
representation = {
'name': 'jpg',
'ext': 'jpg',
'files': filename,
"stagingDir": staging_dir,
"thumbnail": True,
"tags": []
}
# # add Delete tag when temp file was rendered
# if not is_jpeg:
# representation["tags"].append("delete")
instance.data["representations"].append(representation)