From c24d55d4fee0ca28e9478519bb393538269ef81d Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Tue, 17 Dec 2024 22:59:21 +0100 Subject: [PATCH 1/3] Fix OTIO sequence export. --- client/ayon_flame/otio/flame_export.py | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/client/ayon_flame/otio/flame_export.py b/client/ayon_flame/otio/flame_export.py index 79036a5..91bf0bb 100644 --- a/client/ayon_flame/otio/flame_export.py +++ b/client/ayon_flame/otio/flame_export.py @@ -231,8 +231,15 @@ def create_otio_reference(clip_data, media_info, fps=None): otio_ex_ref_item = None - is_sequence = frame_number = utils.get_frame_from_filename(file_name) + # match range pattern e.g. "foo_[1001-1010].ext" + regex_sequence = r"\D*\[(\d)*\-(\d)*\]\D*" + is_sequence = re.match( + regex_sequence, + media_info.file_pattern + ) + if is_sequence: + frame_number = utils.get_frame_from_filename(file_name) file_head = file_name.split(frame_number)[0] start_frame = int(frame_number) padding = len(frame_number) @@ -259,16 +266,25 @@ def create_otio_reference(clip_data, media_info, fps=None): fps ) ) + + # in case old OTIO create sequence as `ExternalReference` except AttributeError: - pass + dirname, file_name = os.path.split(path) + file_name = utils.get_reformatted_filename(file_name, padded=False) + reformated_path = os.path.join(dirname, file_name) + otio_ex_ref_item = otio.schema.ExternalReference( + target_url=reformated_path, + available_range=create_otio_time_range( + media_start, + duration, + fps + ) + ) - if not otio_ex_ref_item: - dirname, file_name = os.path.split(path) - file_name = utils.get_reformatted_filename(file_name, padded=False) - reformated_path = os.path.join(dirname, file_name) - # in case old OTIO or video file create `ExternalReference` + # video/audio file create `ExternalReference` + else: otio_ex_ref_item = otio.schema.ExternalReference( - target_url=reformated_path, + target_url=path, available_range=create_otio_time_range( media_start, duration, From 6cb5ae61f7fee311bda059440333849a48c7d88d Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Wed, 18 Dec 2024 12:50:34 +0100 Subject: [PATCH 2/3] Adjust regex and first_frame detection. --- client/ayon_flame/otio/flame_export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_flame/otio/flame_export.py b/client/ayon_flame/otio/flame_export.py index 91bf0bb..1a8ded1 100644 --- a/client/ayon_flame/otio/flame_export.py +++ b/client/ayon_flame/otio/flame_export.py @@ -232,14 +232,14 @@ def create_otio_reference(clip_data, media_info, fps=None): otio_ex_ref_item = None # match range pattern e.g. "foo_[1001-1010].ext" - regex_sequence = r"\D*\[(\d)*\-(\d)*\]\D*" + regex_sequence = r".*\[(?P\d*)-(?P\d*)\].?" is_sequence = re.match( regex_sequence, media_info.file_pattern ) if is_sequence: - frame_number = utils.get_frame_from_filename(file_name) + frame_number = is_sequence.group("start_frame") file_head = file_name.split(frame_number)[0] start_frame = int(frame_number) padding = len(frame_number) From 5d3ff5e1f8b12a09cb416af045f8e8c9da1625bf Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Mon, 6 Jan 2025 09:54:54 +0100 Subject: [PATCH 3/3] Address feedback from PR. --- client/ayon_flame/otio/flame_export.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client/ayon_flame/otio/flame_export.py b/client/ayon_flame/otio/flame_export.py index 1a8ded1..f8dad0d 100644 --- a/client/ayon_flame/otio/flame_export.py +++ b/client/ayon_flame/otio/flame_export.py @@ -231,15 +231,14 @@ def create_otio_reference(clip_data, media_info, fps=None): otio_ex_ref_item = None - # match range pattern e.g. "foo_[1001-1010].ext" - regex_sequence = r".*\[(?P\d*)-(?P\d*)\].?" - is_sequence = re.match( - regex_sequence, + sequence_match = re.match( + # match range pattern e.g. "foo_[1001-1010].ext" + r".*\[(?P\d*)-(?P\d*)\].?", media_info.file_pattern ) - if is_sequence: - frame_number = is_sequence.group("start_frame") + if sequence_match: + frame_number = sequence_match.group("start_frame") file_head = file_name.split(frame_number)[0] start_frame = int(frame_number) padding = len(frame_number)