AcademySoftwareFoundation / OpenTimelineIO

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

Did OpentimelineIO support clip duration when speed up or slow down? #1280

Open luochaojing opened 2 years ago

luochaojing commented 2 years ago

Feature Request

Did OpentimelineIO support clip duration when speed up or slow down?

Description

For example,

  1. has a video media_reference,duration is [0, 10]。
  2. Add it to a Clip。source_range = [0, 10]
  3. 2.0x Speed up the clip。Clip show in UI,display_range = [0, 5]。

How to description speed and Display_Range

opentime-io Timerange donnot consider speed now? maybe..

Context

meshula commented 2 years ago

Does the LInearTimeWarp address your question?

https://sandflow.github.io/otio-core-specification/#object-model-LinearTimeWarp

luochaojing commented 2 years ago

@meshula thanks for replying。

LinearTimeWarp is an effect descrition speed up or slow down。I kown it。

But my question is:when has a time_effect。Clip duration is not correct no more。I need 【display_range】to description the timerange show in UI。

meshula commented 2 years ago

When you ask a clip about its range, it is always in the clip's time coordinate system. So the clip doesn't know about the time warp. The time warp is between the clip coordinate system, and the parent coordinate system. Usually the clip's parent is a track. So if you call clip.range_in_parent(), you would see the result you expect, a shorter or longer time, because the clip is only shorter or longer from the parent's point of view.

https://opentimelineio.readthedocs.io/en/latest/tutorials/time-ranges.html

luochaojing commented 2 years ago

It mean that,I can define a new class named MyClip extern from otio::Clip。And override "range" method to calculate UI duration with LinearTimeWarp Effect?

jminor commented 2 years ago

Eventually OTIO will include API to compute this, but today we recommend that you write a function to compute the duration you want, not by subclassing. If you subclass Clip, then that will affect serialization which you probably don't want.

jminor commented 2 years ago

Also, we should clarify that when you adjust the time_scalar of a LinearTimewarp, this does not change the duration of the clip, rather it changes the speed of the media played during that clip. So a Clip that is 10 frames long, normally plays 10 frames of media, but with a 200% speed up (time_scalar = 2.0) that Clip is still 10 frames long, but plays 20 frames of media. That is why the Clip's duration() does not change.

luochaojing commented 2 years ago

In OpentimelineIO Code

// Item
RationalTime
Item::duration(ErrorStatus* error_status) const
{
    return trimmed_range(error_status).duration();
}
    TimeRange trimmed_range(ErrorStatus* error_status = nullptr) const
    {
        return _source_range ? *_source_range : available_range(error_status);
    }

accordance the code,the clip is 200% speed up, source_range is 20 frames long, but the duration() method return 20 frames. But it should return 10 frames.

Did I understand true?

Can you should me the values of source_range、trimmed_range、duration in this case? thanks a lot!