AcademySoftwareFoundation / OpenTimelineIO

Open Source API and interchange format for editorial timeline information.
http://opentimeline.io
Apache License 2.0
1.47k stars 294 forks source link

Only one clip added to track when they have the same duration #1796

Open stephanedebove opened 2 months ago

stephanedebove commented 2 months ago

Required:


[ x] I believe this isn't a duplicate topic
[ x] This report is not related to an adapter (I’m not sure, it might now be related to an adapter, but I had this problem in the previous OpenTimelineIO versions, before I was using the fcp_xml adapter)

Select One:

[x ] Incorrect Functionality or bug

Description

I’m using a python script to generate a timeline exported to an xml file. I think I’ve encountered a bug: when I add two clips of the same duration on the same track on my timeline, only one of them is added to my xml file. For instance, this timeline is exported correctly, with two distinct <clipitem> generated in the xml:

Timeline(
    "TimeLine1", 
    Stack(
        tracks, [
            otio.schema.Track(
                name='Video track 1', 
                children=[
                    otio.schema.Clip(
                        name='file.mp4', 
                        media_reference=otio.schema.ExternalReference(
                            target_url='C:\\file.mp4'
                        ), 
                        source_range=otio.opentime.TimeRange(
                            start_time=otio.opentime.RationalTime(value=0, rate=25), 
                            duration=otio.opentime.RationalTime(value=50, rate=25)
                        ), 
                        metadata={}
                    ), 
                    otio.schema.Clip(
                        name='file.mp4', 
                        media_reference=otio.schema.ExternalReference(
                            target_url='C:\\file.mp4'
                        ), 
                        source_range=otio.opentime.TimeRange(
                            start_time=otio.opentime.RationalTime(value=0, rate=25), 
                            duration=otio.opentime.RationalTime(value=75, rate=25)
                        ), 
                        metadata={}
                    )
                ], 
                source_range=None, 
                metadata={}
            )
        ], 
        None, 
        {}
    )
)

(notice both clips have a different duration)

But this timeline is NOT exported correctly, I get only one <clipitem> in my xml file (the behavior I’m expecting is two clips of the same duration following each other on video track 1. Both clips are made from the same file):

Timeline(
    "TimeLine1", 
    Stack(
        tracks, [
            otio.schema.Track(
                name='Video track 1', 
                children=[
                    otio.schema.Clip(
                        name='file.mp4', 
                        media_reference=otio.schema.ExternalReference(
                            target_url='C:\\file.mp4'
                        ), 
                        source_range=otio.opentime.TimeRange(
                            start_time=otio.opentime.RationalTime(value=0, rate=25), 
                            duration=otio.opentime.RationalTime(value=50, rate=25)
                        ), 
                        metadata={}
                    ), 
                    otio.schema.Clip(
                        name='file.mp4', 
                        media_reference=otio.schema.ExternalReference(
                            target_url='C:\\file.mp4'
                        ), 
                        source_range=otio.opentime.TimeRange(
                            start_time=otio.opentime.RationalTime(value=0, rate=25), 
                            duration=otio.opentime.RationalTime(value=50, rate=25)
                        ), 
                        metadata={}
                    )
                ], 
                source_range=None, 
                metadata={}
            )
        ], 
        None, 
        {}
    )
)

I simply export the timeline with

otio.adapters.write_to_file(timeline, file.xml)

Optional


Environment

Operating System: Windows Python version if appropriate: 3.10.14 OpentimelineIO version: opentimelineio-0.17.0 (but I was having the same problem with 0.16)

apetrynet commented 2 months ago

Hi, @stephanedebove

Could you please try to add available_range to your media references? And since it's the same file I believe you can create a shared media reference for both of them.

stephanedebove commented 2 months ago

Hi @apetrynet , thanks for the answer. From what I see available_range is already there. It’s not showing when I do print(timeline) but I can see it in print(f"Available Range: {media_reference.available_range}"):

Available Range: TimeRange(RationalTime(0, 25), RationalTime(250, 25))

apetrynet commented 2 months ago

Does the otio file itself display the two clips as expected in otioview or another app supporting otio natively?

stephanedebove commented 2 months ago

Unfortunately I don’t have any other app supporting otio and I was not able to make otioview work, even following these instructions (otioview mytimeline.otio does not output anything, no error message, nothing): https://opentimelineio.readthedocs.io/en/latest/tutorials/quickstart.html#run-otioview

But it looks like when I export in .otio, the two clips are present (two clips of duration 75 each):

{
    "OTIO_SCHEMA": "Timeline.1",
    "metadata": {
        "fcp_xml": {
            "media": {
                "video": {
                    "format": {
                        "samplecharacteristics": {
                            "anamorphic": "FALSE",
                            "fielddominance": "none",
                            "height": "1080",
                            "pixelaspectratio": "square",
                            "rate": {
                                "ntsc": "TRUE",
                                "timebase": "25"
                            },
                            "width": "1920"
                        }
                    }
                }
            },
            "rate": {
                "ntsc": "TRUE",
                "timebase": "25"
            }
        }
    },
    "name": "TimeLine1",
    "global_start_time": null,
    "tracks": {
        "OTIO_SCHEMA": "Stack.1",
        "metadata": {},
        "name": "tracks",
        "source_range": null,
        "effects": [],
        "markers": [],
        "enabled": true,
        "children": [
            {
                "OTIO_SCHEMA": "Track.1",
                "metadata": {},
                "name": "Video track 1",
                "source_range": null,
                "effects": [],
                "markers": [],
                "enabled": true,
                "children": [
                    {
                        "OTIO_SCHEMA": "Clip.2",
                        "metadata": {},
                        "name": "file.mp4",
                        "source_range": {
                            "OTIO_SCHEMA": "TimeRange.1",
                            "duration": {
                                "OTIO_SCHEMA": "RationalTime.1",
                                "rate": 25.0,
                                "value": 75.0
                            },
                            "start_time": {
                                "OTIO_SCHEMA": "RationalTime.1",
                                "rate": 25.0,
                                "value": 0.0
                            }
                        },
                        "effects": [],
                        "markers": [],
                        "enabled": true,
                        "media_references": {
                            "DEFAULT_MEDIA": {
                                "OTIO_SCHEMA": "ExternalReference.1",
                                "metadata": {},
                                "name": "",
                                "available_range": {
                                    "OTIO_SCHEMA": "TimeRange.1",
                                    "duration": {
                                        "OTIO_SCHEMA": "RationalTime.1",
                                        "rate": 25.0,
                                        "value": 250.0
                                    },
                                    "start_time": {
                                        "OTIO_SCHEMA": "RationalTime.1",
                                        "rate": 25.0,
                                        "value": 0.0
                                    }
                                },
                                "available_image_bounds": null,
                                "target_url": "C:\\file.mp4"
                            }
                        },
                        "active_media_reference_key": "DEFAULT_MEDIA"
                    },
                    {
                        "OTIO_SCHEMA": "Clip.2",
                        "metadata": {},
                        "name": "file.mp4",
                        "source_range": {
                            "OTIO_SCHEMA": "TimeRange.1",
                            "duration": {
                                "OTIO_SCHEMA": "RationalTime.1",
                                "rate": 25.0,
                                "value": 75.0
                            },
                            "start_time": {
                                "OTIO_SCHEMA": "RationalTime.1",
                                "rate": 25.0,
                                "value": 0.0
                            }
                        },
                        "effects": [],
                        "markers": [],
                        "enabled": true,
                        "media_references": {
                            "DEFAULT_MEDIA": {
                                "OTIO_SCHEMA": "ExternalReference.1",
                                "metadata": {},
                                "name": "",
                                "available_range": {
                                    "OTIO_SCHEMA": "TimeRange.1",
                                    "duration": {
                                        "OTIO_SCHEMA": "RationalTime.1",
                                        "rate": 25.0,
                                        "value": 250.0
                                    },
                                    "start_time": {
                                        "OTIO_SCHEMA": "RationalTime.1",
                                        "rate": 25.0,
                                        "value": 0.0
                                    }
                                },
                                "available_image_bounds": null,
                                "target_url": "C:\\file.mp4"
                            }
                        },
                        "active_media_reference_key": "DEFAULT_MEDIA"
                    }
                ],
                "kind": "Video"
            }
        ]
    }
}

whereas when I export in xml, only one clip is added:

<xmeml version="4">
    <project>
        <name>TimeLine1</name>
        <children>
            <sequence id="sequence-1">
                <media>
                    <video>
                        <format>
                            <samplecharacteristics>
                                <anamorphic>FALSE</anamorphic>
                                <fielddominance>none</fielddominance>
                                <height>1080</height>
                                <pixelaspectratio>square</pixelaspectratio>
                                <rate>
                                    <ntsc>TRUE</ntsc>
                                    <timebase>25</timebase>
                                </rate>
                                <width>1920</width>
                            </samplecharacteristics>
                        </format>
                        <track>
                            <clipitem frameBlend="FALSE" id="clipitem-1">
                                <file id="file-1">
                                    <pathurl>C:\file.mp4</pathurl>
                                    <name>file.mp4</name>
                                    <rate>
                                        <timebase>25</timebase>
                                        <ntsc>FALSE</ntsc>
                                    </rate>
                                    <duration>250</duration>
                                    <timecode>
                                        <rate>
                                            <timebase>25</timebase>
                                            <ntsc>FALSE</ntsc>
                                        </rate>
                                        <string>00:00:00:00</string>
                                        <frame>0</frame>
                                        <displayformat>NDF</displayformat>
                                    </timecode>
                                    <media>
                                        <video />
                                        <audio />
                                    </media>
                                </file>
                                <name>file.mp4</name>
                                <rate>
                                    <timebase>25</timebase>
                                    <ntsc>FALSE</ntsc>
                                </rate>
                                <rate>
                                    <timebase>25</timebase>
                                    <ntsc>FALSE</ntsc>
                                </rate>
                                <duration>75</duration>
                                <start>0</start>
                                <end>75</end>
                                <in>0</in>
                                <out>75</out>
                            </clipitem>
                            <clipitem id="clipitem-1" />
                        </track>
                    </video>
                    <audio />
                </media>
                <name>TimeLine1</name>
                <duration>150</duration>
                <rate>
                    <timebase>25</timebase>
                    <ntsc>FALSE</ntsc>
                </rate>
            </sequence>
        </children>
    </project>
</xmeml>

so that would mean it’s an adapter problem? Should I move my bug report somewhere else?

apetrynet commented 2 months ago

Yeah, sounds like we might be in adapter territory. You can submit an issue here for the fcp adapter.

Just out of curiosity, what happens if you add a gap or another clip between the two "twin clips"?

stephanedebove commented 2 months ago

Same thing: the twin clip appearing last on the track is not displayed. Thanks I’ll post there.

apetrynet commented 2 months ago

OK, thanks for checking.

Unless anyone else suspects this is an otio core thing I guess we can close this issue as you've opened one in the adapter repo?

I'll let the TSC make the call in the upcoming meeting.

Thanks for submitting @stephanedebove