Skip to content

cmx3600 adapter assumes tracks start at 00:00:00:00 #6

Description

@douglascomet

The editors I work with generate .edl(s) that typically start at or around 01:00:00:00. The reason they do this is because of the convention established by broadcast television to start at 1 hour. The editors also relayed that most, if not all, NLEs default their timelines to start at 01:00:00:00. Ideally, we would not have to conform how editors initialize their timelines and the adapters just react to what an editor choose to set up their timeline.

Here is a sample .edl

TITLE:   LA_previs_v0014 
FCM: NON-DROP FRAME
001  DARK_GRA V     C        01:00:00:00 01:00:01:14 00:59:58:00 00:59:59:14 
* FROM CLIP NAME:  DARK GRADIENT 2.TIF

When I run he following code, the cmx3600 adapter throws an error.

import opentimelineio as otio
path = r"Y:\dhalley\test.edl"
input_otio = otio.adapters.read_from_file(path)
track = input_otio.tracks[0]
print(f"clip: {track.clip_if()[0]}")
track_range = track.trimmed_range()
print(f"track_range: {track_range}")
start_time_code = track_range.start_time.to_timecode()
clip: Clip("DARK GRADIENT 2.TIF", MissingReference('', None, None, {}), TimeRange(RationalTime(86400, 24), RationalTime(38, 24)), {'cmx_3600': {'reel': 'DARK_GRA'}})
track_range: TimeRange(RationalTime(-86352, 24), RationalTime(3483, 24))
Traceback (most recent call last):
  File "C:\Users\doug.halley\AppData\Roaming\JetBrains\PyCharm2023.2\scratches\test_edl_parser.py", line 8, in <module>
    start_time_code = track_range.start_time.to_timecode()
ValueError: value cannot be negative here

I looked through the cmx3600 adapter code and stumbled across this snippet, where a RationalTime is constructed at 00:00:00:00.
image

This code explains how the track in the above example becomes negative. This code is use to initialize the the track's source range and I think the source range should be based on the timing of the first clip found in the .edl instead of zero. I think this can be accomplished by doing the following:

            if track.source_range is None:
                zero = opentime.RationalTime(0, edl_rate)
                track.source_range = opentime.TimeRange(
                    start_time=record_in,
                    duration=zero
                )

This simple change has the start time of the track be the record_in determined from the clip and the duration be zero. From what I can tell, the duration of the track starts at zero because it gets extended later in the cmx3600 adapter based on the clips found during parsing of the .edl.

Another QOL of improvement that could be made to the cmx3600 adapter would be setting the timeline's global_start_time in this same code block. Currently the global_start_time is never set. Like the start_time of the track, the start_time of timeline should also be based on the first clip found in the .edl. With that in mind, the previous code suggestion would look like this:

            if track.source_range is None:
                zero = opentime.RationalTime(0, edl_rate)
                track.source_range = opentime.TimeRange(
                    start_time=record_in,
                    duration=zero
                )
                self.timeline.global_start_time = record_in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions