Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/opentime/rationalTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ RationalTime::to_timecode(
) const {

*error_status = ErrorStatus();

double frames_in_target_rate = this->value_rescaled_to(rate);

if (_value < 0) {
if (frames_in_target_rate < 0) {
*error_status = ErrorStatus(ErrorStatus::NEGATIVE_VALUE);
return std::string();
}
Expand Down Expand Up @@ -252,7 +254,7 @@ RationalTime::to_timecode(
(std::round(rate) * 60) - dropframes);

// If the number of frames is more than 24 hours, roll over clock
double value = std::fmod(_value, frames_per_24_hours);
double value = std::fmod(frames_in_target_rate, frames_per_24_hours);

if (rate_is_dropframe) {
int ten_minute_chunks = static_cast<int>(std::floor(value/frames_per_10_minutes));
Expand Down
10 changes: 9 additions & 1 deletion tests/test_opentime.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ def test_passing_ndf_tc_at_df_rate(self):

tc2 = otio.opentime.to_timecode(
otio.opentime.RationalTime(frames, 29.97),
30
29.97,
drop_frame=False
)
self.assertEqual(tc2, NDF_TC)

Expand Down Expand Up @@ -993,6 +994,13 @@ def test_to_timecode_mixed_rates(self):
self.assertEqual(timecode, otio.opentime.to_timecode(t, 24))
self.assertNotEqual(timecode, otio.opentime.to_timecode(t, 12))

time1 = otio.opentime.RationalTime(24.0, 24.0)
time2 = otio.opentime.RationalTime(1.0, 1.0)
self.assertEqual(
otio.opentime.to_timecode(time1, 24.0),
otio.opentime.to_timecode(time2, 24.0)
)

def test_to_frames_mixed_rates(self):
frame = 100
t = otio.opentime.from_frames(frame, 24)
Expand Down