resolve: wip publishing and creation

This commit is contained in:
Jakub Jezek 2020-12-23 15:13:32 +01:00
parent 600f60188c
commit a04aab3371
No known key found for this signature in database
GPG key ID: C4B96E101D2A47F3
7 changed files with 62 additions and 35 deletions

View file

@ -83,7 +83,8 @@ from .editorial import (
convert_to_padded_path,
trim_media_range,
range_from_frames,
frames_to_secons
frames_to_secons,
make_sequence_collection
)
terminal = Terminal
@ -154,5 +155,6 @@ __all__ = [
"otio_range_to_frame_range",
"trim_media_range",
"range_from_frames",
"frames_to_secons"
"frames_to_secons",
"make_sequence_collection"
]

View file

@ -1,4 +1,6 @@
import os
import re
import clique
from opentimelineio import opentime
from opentimelineio.opentime import (
to_frames, RationalTime, TimeRange)
@ -130,3 +132,29 @@ def frames_to_secons(frames, framerate):
"""
rt = opentime.from_frames(frames, framerate)
return opentime.to_seconds(rt)
def make_sequence_collection(path, otio_range, metadata):
"""
Make collection from path otio range and otio metadata.
Args:
path (str): path to image sequence with `%d`
otio_range (otio.opentime.TimeRange): range to be used
metadata (dict): data where padding value can be found
Returns:
list: dir_path (str): path to sequence, collection object
"""
if "%" not in path:
return None
file_name = os.path.basename(path)
dir_path = os.path.dirname(path)
head = file_name.split("%")[0]
tail = os.path.splitext(file_name)[-1]
first, last = otio_range_to_frame_range(otio_range)
collection = clique.Collection(
head=head, tail=tail, padding=metadata["padding"])
collection.indexes.update([i for i in range(first, (last + 1))])
return dir_path, collection