OpenTimelineIO icon indicating copy to clipboard operation
OpenTimelineIO copied to clipboard

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

Open luochaojing opened this issue 2 years ago • 7 comments

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

luochaojing avatar Apr 21 '22 03:04 luochaojing

Does the LInearTimeWarp address your question?

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

meshula avatar Apr 21 '22 04:04 meshula

@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。

luochaojing avatar Apr 21 '22 04:04 luochaojing

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

meshula avatar Apr 21 '22 04:04 meshula

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?

luochaojing avatar Apr 21 '22 07:04 luochaojing

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 avatar Apr 21 '22 21:04 jminor

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.

jminor avatar Apr 22 '22 23:04 jminor

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!

luochaojing avatar Apr 24 '22 02:04 luochaojing