mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #1422 from pypeclub/bugfix/1421-resolve-fix-loading-clips-to-timeline
This commit is contained in:
commit
a8a4da9d5a
8 changed files with 82 additions and 44 deletions
|
|
@ -164,11 +164,21 @@ def create_media_pool_item(fpath: str,
|
|||
# try to search in bin if the clip does not exist
|
||||
existing_mpi = get_media_pool_item(fpath, root_bin)
|
||||
|
||||
print(">>>>> existing_mpi: {}".format(existing_mpi))
|
||||
if not existing_mpi:
|
||||
media_pool_item = media_storage.AddItemsToMediaPool(fpath)
|
||||
print(media_pool_item)
|
||||
print("___ fpath: {}".format(fpath))
|
||||
dirname, file = os.path.split(fpath)
|
||||
_name, ext = os.path.splitext(file)
|
||||
print(dirname)
|
||||
media_pool_items = media_storage.AddItemListToMediaPool(os.path.normpath(dirname))
|
||||
print(media_pool_items)
|
||||
# pop the returned dict on first item as resolve data object is such
|
||||
return media_pool_item.pop(1.0)
|
||||
if media_pool_items:
|
||||
media_pool_item = [mpi for mpi in media_pool_items
|
||||
if ext in mpi.GetClipProperty("File Path")]
|
||||
return media_pool_item.pop()
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return existing_mpi
|
||||
|
||||
|
|
@ -189,7 +199,8 @@ def get_media_pool_item(fpath, root: object = None) -> object:
|
|||
fname = os.path.basename(fpath)
|
||||
|
||||
for _mpi in root.GetClipList():
|
||||
_mpi_name = _mpi.GetClipProperty("File Name")["File Name"]
|
||||
print(">>> _mpi: {}".format(_mpi.GetClipProperty("File Name")))
|
||||
_mpi_name = _mpi.GetClipProperty("File Name")
|
||||
_mpi_name = get_reformated_path(_mpi_name, first=True)
|
||||
if fname in _mpi_name:
|
||||
return _mpi
|
||||
|
|
@ -215,8 +226,8 @@ def create_timeline_item(media_pool_item: object,
|
|||
# get all variables
|
||||
project = get_current_project()
|
||||
media_pool = project.GetMediaPool()
|
||||
clip_property = media_pool_item.GetClipProperty()
|
||||
clip_name = clip_property["File Name"]
|
||||
_clip_property = media_pool_item.GetClipProperty
|
||||
clip_name = _clip_property("File Name")
|
||||
timeline = timeline or get_current_timeline()
|
||||
|
||||
# if timeline was used then switch it to current timeline
|
||||
|
|
@ -231,7 +242,6 @@ def create_timeline_item(media_pool_item: object,
|
|||
clip_data.update({"endFrame": source_end})
|
||||
|
||||
print(clip_data)
|
||||
print(clip_property)
|
||||
# add to timeline
|
||||
media_pool.AppendToTimeline([clip_data])
|
||||
|
||||
|
|
@ -257,8 +267,8 @@ def get_timeline_item(media_pool_item: object,
|
|||
Returns:
|
||||
object: resolve.TimelineItem
|
||||
"""
|
||||
clip_property = media_pool_item.GetClipProperty()
|
||||
clip_name = clip_property["File Name"]
|
||||
_clip_property = media_pool_item.GetClipProperty
|
||||
clip_name = _clip_property("File Name")
|
||||
output_timeline_item = None
|
||||
timeline = timeline or get_current_timeline()
|
||||
|
||||
|
|
@ -267,8 +277,8 @@ def get_timeline_item(media_pool_item: object,
|
|||
|
||||
for _ti_data in get_current_timeline_items():
|
||||
_ti_clip = _ti_data["clip"]["item"]
|
||||
_ti_clip_property = _ti_clip.GetMediaPoolItem().GetClipProperty()
|
||||
if clip_name in _ti_clip_property["File Name"]:
|
||||
_ti_clip_property = _ti_clip.GetMediaPoolItem().GetClipProperty
|
||||
if clip_name in _ti_clip_property("File Name"):
|
||||
output_timeline_item = _ti_clip
|
||||
|
||||
return output_timeline_item
|
||||
|
|
@ -541,15 +551,15 @@ def create_compound_clip(clip_data, name, folder):
|
|||
clip_attributes = get_clip_attributes(clip_item)
|
||||
|
||||
mp_item = clip_item.GetMediaPoolItem()
|
||||
mp_props = mp_item.GetClipProperty()
|
||||
_mp_props = mp_item.GetClipProperty
|
||||
|
||||
mp_first_frame = int(mp_props["Start"])
|
||||
mp_last_frame = int(mp_props["End"])
|
||||
mp_first_frame = int(_mp_props("Start"))
|
||||
mp_last_frame = int(_mp_props("End"))
|
||||
|
||||
# initialize basic source timing for otio
|
||||
ci_l_offset = clip_item.GetLeftOffset()
|
||||
ci_duration = clip_item.GetDuration()
|
||||
rate = float(mp_props["FPS"])
|
||||
rate = float(_mp_props("FPS"))
|
||||
|
||||
# source rational times
|
||||
mp_in_rc = opentime.RationalTime((ci_l_offset), rate)
|
||||
|
|
@ -606,7 +616,7 @@ def create_compound_clip(clip_data, name, folder):
|
|||
cct.SetMetadata(self.pype_tag_name, clip_attributes)
|
||||
|
||||
# reset start timecode of the compound clip
|
||||
cct.SetClipProperty("Start TC", mp_props["Start TC"])
|
||||
cct.SetClipProperty("Start TC", _mp_props("Start TC"))
|
||||
|
||||
# swap clips on timeline
|
||||
swap_clips(clip_item, cct, in_frame, out_frame)
|
||||
|
|
@ -632,8 +642,8 @@ def swap_clips(from_clip, to_clip, to_in_frame, to_out_frame):
|
|||
bool: True if successfully replaced
|
||||
|
||||
"""
|
||||
clip_prop = to_clip.GetClipProperty()
|
||||
to_clip_name = clip_prop["File Name"]
|
||||
_clip_prop = to_clip.GetClipProperty
|
||||
to_clip_name = _clip_prop("File Name")
|
||||
# add clip item as take to timeline
|
||||
take = from_clip.AddTake(
|
||||
to_clip,
|
||||
|
|
|
|||
|
|
@ -379,9 +379,10 @@ class ClipLoader:
|
|||
|
||||
# create mediaItem in active project bin
|
||||
# create clip media
|
||||
|
||||
media_pool_item = lib.create_media_pool_item(
|
||||
self.data["path"], self.active_bin)
|
||||
clip_property = media_pool_item.GetClipProperty()
|
||||
_clip_property = media_pool_item.GetClipProperty
|
||||
|
||||
# get handles
|
||||
handle_start = self.data["versionData"].get("handleStart")
|
||||
|
|
@ -391,10 +392,10 @@ class ClipLoader:
|
|||
if handle_end is None:
|
||||
handle_end = int(self.data["assetData"]["handleEnd"])
|
||||
|
||||
source_in = int(clip_property["Start"])
|
||||
source_out = int(clip_property["End"])
|
||||
source_in = int(_clip_property("Start"))
|
||||
source_out = int(_clip_property("End"))
|
||||
|
||||
if clip_property["Type"] == "Video":
|
||||
if _clip_property("Type") == "Video":
|
||||
source_in += handle_start
|
||||
source_out -= handle_end
|
||||
|
||||
|
|
@ -420,8 +421,8 @@ class ClipLoader:
|
|||
# create clip media
|
||||
media_pool_item = lib.create_media_pool_item(
|
||||
self.data["path"], self.active_bin)
|
||||
clip_property = media_pool_item.GetClipProperty()
|
||||
clip_name = clip_property["File Name"]
|
||||
_clip_property = media_pool_item.GetClipProperty
|
||||
clip_name = _clip_property("File Name")
|
||||
|
||||
# get handles
|
||||
handle_start = self.data["versionData"].get("handleStart")
|
||||
|
|
@ -431,8 +432,8 @@ class ClipLoader:
|
|||
if handle_end is None:
|
||||
handle_end = int(self.data["assetData"]["handleEnd"])
|
||||
|
||||
source_in = int(clip_property["Start"])
|
||||
source_out = int(clip_property["End"])
|
||||
source_in = int(_clip_property("Start"))
|
||||
source_out = int(_clip_property("End"))
|
||||
|
||||
resolve.swap_clips(
|
||||
timeline_item,
|
||||
|
|
|
|||
|
|
@ -33,8 +33,11 @@ def create_otio_time_range(start_frame, frame_duration, fps):
|
|||
|
||||
def create_otio_reference(media_pool_item):
|
||||
metadata = _get_metadata_media_pool_item(media_pool_item)
|
||||
mp_clip_property = media_pool_item.GetClipProperty()
|
||||
path = mp_clip_property["File Path"]
|
||||
print("media pool item: {}".format(media_pool_item.GetName()))
|
||||
|
||||
_mp_clip_property = media_pool_item.GetClipProperty
|
||||
|
||||
path = _mp_clip_property("File Path")
|
||||
reformat_path = utils.get_reformated_path(path, padded=True)
|
||||
padding = utils.get_padding_from_path(path)
|
||||
|
||||
|
|
@ -45,13 +48,12 @@ def create_otio_reference(media_pool_item):
|
|||
})
|
||||
|
||||
# get clip property regarding to type
|
||||
mp_clip_property = media_pool_item.GetClipProperty()
|
||||
fps = float(mp_clip_property["FPS"])
|
||||
if mp_clip_property["Type"] == "Video":
|
||||
frame_start = int(mp_clip_property["Start"])
|
||||
frame_duration = int(mp_clip_property["Frames"])
|
||||
fps = float(_mp_clip_property("FPS"))
|
||||
if _mp_clip_property("Type") == "Video":
|
||||
frame_start = int(_mp_clip_property("Start"))
|
||||
frame_duration = int(_mp_clip_property("Frames"))
|
||||
else:
|
||||
audio_duration = str(mp_clip_property["Duration"])
|
||||
audio_duration = str(_mp_clip_property("Duration"))
|
||||
frame_start = 0
|
||||
frame_duration = int(utils.timecode_to_frames(
|
||||
audio_duration, float(fps)))
|
||||
|
|
@ -124,10 +126,10 @@ def create_otio_markers(track_item, fps):
|
|||
|
||||
def create_otio_clip(track_item):
|
||||
media_pool_item = track_item.GetMediaPoolItem()
|
||||
mp_clip_property = media_pool_item.GetClipProperty()
|
||||
_mp_clip_property = media_pool_item.GetClipProperty
|
||||
|
||||
if not self.project_fps:
|
||||
fps = mp_clip_property["FPS"]
|
||||
fps = float(_mp_clip_property("FPS"))
|
||||
else:
|
||||
fps = self.project_fps
|
||||
|
||||
|
|
@ -140,9 +142,9 @@ def create_otio_clip(track_item):
|
|||
fps
|
||||
)
|
||||
|
||||
if mp_clip_property["Type"] == "Audio":
|
||||
if _mp_clip_property("Type") == "Audio":
|
||||
return_clips = list()
|
||||
audio_chanels = mp_clip_property["Audio Ch"]
|
||||
audio_chanels = _mp_clip_property("Audio Ch")
|
||||
for channel in range(0, int(audio_chanels)):
|
||||
clip = otio.schema.Clip(
|
||||
name=f"{name}_{channel}",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
from avalon import io, api
|
||||
from openpype.hosts import resolve
|
||||
from copy import deepcopy
|
||||
|
||||
from importlib import reload
|
||||
from openpype.hosts.resolve.api import lib, plugin
|
||||
reload(plugin)
|
||||
reload(lib)
|
||||
|
||||
class LoadClip(resolve.TimelineItemLoader):
|
||||
"""Load a subset to timeline as clip
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
#! python3
|
||||
import avalon.api as avalon
|
||||
import openpype
|
||||
import openpype.hosts.resolve as bmdvr
|
||||
|
||||
|
||||
def file_processing(fpath):
|
||||
media_pool_item = bmdvr.create_media_pool_item(fpath)
|
||||
print(media_pool_item)
|
||||
|
||||
track_item = bmdvr.create_timeline_item(media_pool_item)
|
||||
print(track_item)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
path = "C:/CODE/__openpype_projects/jtest03dev/shots/sq01/mainsq01sh030/publish/plate/plateMain/v006/jt3d_mainsq01sh030_plateMain_v006.0996.exr"
|
||||
|
||||
openpype.install()
|
||||
# activate resolve from openpype
|
||||
avalon.install(bmdvr)
|
||||
|
||||
file_processing(path)
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"nuke/12-2",
|
||||
"nukex/12-2",
|
||||
"hiero/12-2",
|
||||
"resolve/16",
|
||||
"resolve/stable",
|
||||
"houdini/18-5",
|
||||
"blender/2-91",
|
||||
"harmony/20",
|
||||
|
|
|
|||
|
|
@ -758,9 +758,9 @@
|
|||
"RESOLVE_DEV": "True"
|
||||
},
|
||||
"variants": {
|
||||
"16": {
|
||||
"stable": {
|
||||
"enabled": true,
|
||||
"variant_label": "16",
|
||||
"variant_label": "stable",
|
||||
"use_python_2": false,
|
||||
"executables": {
|
||||
"windows": [
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@
|
|||
"name": "template_host_variant",
|
||||
"template_data": [
|
||||
{
|
||||
"app_variant_label": "16",
|
||||
"app_variant": "16"
|
||||
"app_variant_label": "stable",
|
||||
"app_variant": "stable"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue