Rational: conversion to opentime take framerate
Add a frame rate option to the conversion to opentime rationals as otio generaly expects rationals to be in the form value/framerate. Also add a check to make sure the rational is not in the form 0/0 as this can cause errors with OTIO.
This commit is contained in:
@@ -103,10 +103,12 @@ AVRational rational::toAVRational() const
|
||||
}
|
||||
|
||||
#ifdef USE_OTIO
|
||||
opentime::RationalTime rational::toRationalTime() const
|
||||
opentime::RationalTime rational::toRationalTime(double framerate) const
|
||||
{
|
||||
// Is this the best way of doing this?
|
||||
return opentime::RationalTime::from_seconds(toDouble());
|
||||
// Olive can store rationals as 0/0 which causes errors in OTIO
|
||||
opentime::RationalTime time = opentime::RationalTime(numer_, denom_ == 0 ? 1 : denom_);
|
||||
return time.rescaled_to(framerate);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -101,7 +101,8 @@ public:
|
||||
AVRational toAVRational() const;
|
||||
|
||||
#ifdef USE_OTIO
|
||||
opentime::RationalTime toRationalTime() const;
|
||||
// Convert Olive ratioanls to opentime rationals with the given framerate (defaults to 24)
|
||||
opentime::RationalTime toRationalTime(double framerate = 24) const;
|
||||
#endif
|
||||
|
||||
// Produce "flipped" version
|
||||
|
||||
@@ -144,8 +144,8 @@ opentimelineio::v1_0::Track *SaveOTIOTask::SerializeTrack(TrackOutput *track)
|
||||
}
|
||||
case Block::kGap:
|
||||
{
|
||||
otio_block = new opentimelineio::v1_0::Gap(
|
||||
opentimelineio::v1_0::TimeRange(block->in().toRationalTime(), block->length().toRationalTime()),
|
||||
otio_block = new opentimelineio::v1_0::Gap(opentimelineio::v1_0::TimeRange(block->in().toRationalTime(),
|
||||
block->length().toRationalTime()),
|
||||
block->GetLabel().toStdString()
|
||||
);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user