diff --git a/app/node/project/footage/footage.cpp b/app/node/project/footage/footage.cpp index 1070bc0bc..46ee75b83 100644 --- a/app/node/project/footage/footage.cpp +++ b/app/node/project/footage/footage.cpp @@ -350,7 +350,7 @@ void Footage::Hash(const QString& output, QCryptographicHash &hash, const ration // Footage timestamp if (params.video_type() != VideoParams::kVideoTypeStill) { - rational adjusted_time = AdjustTimeByLoopMode(time, loop_mode(), GetLength(), params.video_type()); + rational adjusted_time = AdjustTimeByLoopMode(time, loop_mode(), GetLength(), params.video_type(), params.frame_rate_as_time_base()); if (!adjusted_time.isNaN()) { int64_t video_ts = Timecode::time_to_timestamp(adjusted_time, params.time_base()); @@ -446,7 +446,7 @@ bool TimeIsOutOfBounds(const rational& time, const rational& length) return time < 0 || time >= length; } -rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mode, const rational &length, VideoParams::Type type) +rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mode, const rational &length, VideoParams::Type type, const rational& timebase) { if (type == VideoParams::kVideoTypeStill) { // No looping for still images @@ -461,7 +461,7 @@ rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mod break; case kLoopModeClamp: // Clamp footage time to length - time = clamp(time, rational(0), length); + time = clamp(time, rational(0), length - timebase); break; case kLoopModeLoop: // Loop footage time around job length diff --git a/app/node/project/footage/footage.h b/app/node/project/footage/footage.h index 749f72496..4b29118c5 100644 --- a/app/node/project/footage/footage.h +++ b/app/node/project/footage/footage.h @@ -191,7 +191,7 @@ public: virtual NodeOutput GetConnectedSampleOutput() override; - static rational AdjustTimeByLoopMode(rational time, LoopMode loop_mode, const rational& length, VideoParams::Type type); + static rational AdjustTimeByLoopMode(rational time, LoopMode loop_mode, const rational& length, VideoParams::Type type, const rational &timebase); static const QString kFilenameInput; static const QString kLoopModeInput; diff --git a/app/node/traverser.cpp b/app/node/traverser.cpp index 83e5bed94..e16683755 100644 --- a/app/node/traverser.cpp +++ b/app/node/traverser.cpp @@ -286,7 +286,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const QString& output, co FootageJob job = v.data().value(); if (job.type() == Track::kVideo) { - rational footage_time = Footage::AdjustTimeByLoopMode(range.in(), job.loop_mode(), job.length(), job.video_params().video_type()); + rational footage_time = Footage::AdjustTimeByLoopMode(range.in(), job.loop_mode(), job.length(), job.video_params().video_type(), job.video_params().frame_rate_as_time_base()); if (!footage_time.isNaN()) { QVariant value = ProcessVideoFootage(job, footage_time);