diff --git a/app/common/rational.cpp b/app/common/rational.cpp index 2160e3f0e..ff44bbd89 100644 --- a/app/common/rational.cpp +++ b/app/common/rational.cpp @@ -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 diff --git a/app/common/rational.h b/app/common/rational.h index 358ea9697..8074c9b07 100644 --- a/app/common/rational.h +++ b/app/common/rational.h @@ -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 diff --git a/app/task/project/saveotio/saveotio.cpp b/app/task/project/saveotio/saveotio.cpp index 0fdb91b61..890d11dfd 100644 --- a/app/task/project/saveotio/saveotio.cpp +++ b/app/task/project/saveotio/saveotio.cpp @@ -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;