Skip to content

Commit 843c062

Browse files
committed
Fix Motion Tracker keyframes not applying after save/reload
MotionTrackerModel::trackingData parsed each keyframe's time key with QString::toInt, which only accepts integer frame numbers ("5"). When a project is saved, Shotcut serializes animated properties (including the opencv.tracker `results`) in clock time format (00:00:00.167). After a save+reload, toInt then failed on every entry, trackingData returned an empty list, and "Load Keyframes from Motion Tracker" silently applied zero keyframes (the masked rect stayed static). Accept both frame-number and clock/timecode keys. The parsed frame value is not used downstream (only the rectangles are consumed by applyTracking and reset), so fall back to the running index when toInt fails. Claude-Session: https://claude.ai/code/session_019w5rMv8av4uAba3MBJhhqD
1 parent 76c0055 commit 843c062

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/models/motiontrackermodel.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,18 @@ QList<MotionTrackerModel::TrackingItem> MotionTrackerModel::trackingData(const Q
270270
for (const auto &i : l) {
271271
auto pair = i.split("~=");
272272
if (pair.size() == 2) {
273-
auto frame = pair.at(0).toInt(&ok);
273+
// The keyframe time may be serialized either as a frame number
274+
// ("5") or as a clock value ("00:00:00.167"), depending on the MLT
275+
// time format used when the project was written. toInt() only
276+
// parses the frame-number form; for the clock form it fails, so we
277+
// fall back to the running index. Only the rectangles are consumed
278+
// downstream, so the exact frame value is not significant here.
279+
int frame = pair.at(0).toInt(&ok);
280+
if (!ok)
281+
frame = int(result.size());
274282
props.set("", pair.at(1).toLatin1().constData());
275283
auto rect = props.get_rect("");
276-
if (ok) {
277-
result << TrackingItem{frame, QRectF(rect.x, rect.y, rect.w, rect.h)};
278-
}
284+
result << TrackingItem{frame, QRectF(rect.x, rect.y, rect.w, rect.h)};
279285
}
280286
}
281287
return result;

0 commit comments

Comments
 (0)