feat(resolve): create compound clip wip

This commit is contained in:
Jakub Jezek 2020-06-23 12:47:06 +03:00
parent 48c163a331
commit 8e91764c4c
No known key found for this signature in database
GPG key ID: C4B96E101D2A47F3
2 changed files with 26 additions and 12 deletions

View file

@ -1,4 +1,5 @@
import sys import sys
import json
from pype.api import Logger from pype.api import Logger
log = Logger().get_logger(__name__, "resolve") log = Logger().get_logger(__name__, "resolve")
@ -140,14 +141,14 @@ def create_compound_clip(clip_data, folder, presets):
# get metadata # get metadata
mp_item = clip_item.GetMediaPoolItem() mp_item = clip_item.GetMediaPoolItem()
mp_props = mp_item.GetClipProperty() mp_props = mp_item.GetClipProperty()
metadata = get_metadata_from_clip(clip_item) clip_attributes = get_clip_attributes(clip_item)
mp = project.GetMediaPool() mp = project.GetMediaPool()
# keep original sequence # keep original sequence
sq_origin = sequence sq_origin = sequence
# print(f"_ sequence: {sequence}") print(f"_ sequence: {sequence}")
# print(f"_ metadata: {pformat(metadata)}") print(f"_ metadata: {pformat(clip_attributes)}")
# Set current folder to input media_pool_folder: # Set current folder to input media_pool_folder:
mp.SetCurrentFolder(folder) mp.SetCurrentFolder(folder)
@ -163,7 +164,12 @@ def create_compound_clip(clip_data, folder, presets):
# Create empty timeline in current folder and give name: # Create empty timeline in current folder and give name:
cct = mp.CreateEmptyTimeline(name) cct = mp.CreateEmptyTimeline(name)
print(f"_ cct: {cct}")
# check if clip doesnt exist already:
clips = folder.GetClipList()
cct = next((c for c in clips
if c.GetName() in name), None)
print(f"_ cct created: {cct}")
# Set current timeline to created timeline: # Set current timeline to created timeline:
project.SetCurrentTimeline(cct) project.SetCurrentTimeline(cct)
@ -180,10 +186,19 @@ def create_compound_clip(clip_data, folder, presets):
# Set current timeline to the working timeline: # Set current timeline to the working timeline:
project.SetCurrentTimeline(sq_origin) project.SetCurrentTimeline(sq_origin)
# Add collected metadata to the comound clip: # Add collected metadata and attributes to the comound clip:
done = mp_item.SetClipProperty("pypeMetadata", metadata) clip_attributes["VFX Notes"] = mp_item.GetMetadata(
"VFX Notes")["VFX Notes"]
clip_attributes = json.dumps(clip_attributes)
for k, v in mp_item.GetMetadata().items():
done = cct.SetMetadata(k, v)
done = cct.SetMetadata("VFX Notes", clip_attributes)
print(f"_ done2: {done}") print(f"_ done2: {done}")
# # add clip item as take to timeline
# AddTake(cct, startFrame, endFrame)
return cct return cct
@ -203,15 +218,15 @@ def validate_tc(x):
print('Invalid timecode. Try again.') print('Invalid timecode. Try again.')
def get_metadata_from_clip(clip): def get_clip_attributes(clip):
""" """
Collect all metadata from resolve timeline item Collect basic atrributes from resolve timeline item
Args: Args:
clip (resolve.TimelineItem): timeline item object clip (resolve.TimelineItem): timeline item object
Returns: Returns:
dict: all collected metadata as key: values dict: all collected attributres as key: values
""" """
mp_item = clip.GetMediaPoolItem() mp_item = clip.GetMediaPoolItem()
@ -222,7 +237,6 @@ def get_metadata_from_clip(clip):
"clipRightOffset": clip.GetRightOffset(), "clipRightOffset": clip.GetRightOffset(),
"clipMarkers": clip.GetMarkers(), "clipMarkers": clip.GetMarkers(),
"clipFlags": clip.GetFlagList(), "clipFlags": clip.GetFlagList(),
"sourceMetadata": mp_item.GetMetadata(),
"sourceId": mp_item.GetMediaId(), "sourceId": mp_item.GetMediaId(),
"sourceProperties": mp_item.GetClipProperty() "sourceProperties": mp_item.GetClipProperty()
} }

View file

@ -70,9 +70,9 @@ def get_resolve_module():
sys.exit() sys.exit()
# assign global var and return # assign global var and return
bmdvr = bmd.scriptapp("Resolve") bmdvr = bmd.scriptapp("Resolve")
bmdvf = bmd.scriptapp("Fusion") # bmdvf = bmd.scriptapp("Fusion")
resolve.bmdvr = bmdvr resolve.bmdvr = bmdvr
resolve.bmdvf = bmdvf resolve.bmdvf = bmdvr.Fusion()
log.info(("Assigning resolve module to " log.info(("Assigning resolve module to "
f"`pype.hosts.resolve.bmdvr`: {resolve.bmdvr}")) f"`pype.hosts.resolve.bmdvr`: {resolve.bmdvr}"))
log.info(("Assigning resolve module to " log.info(("Assigning resolve module to "