From be0d857e388c6066b42a19e7bbc36f1a93893fed Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 18 Dec 2019 01:21:25 +1100 Subject: [PATCH] snap footage imports to the timeline timebase Earlier, footage that was not the same frame rate as the sequence had the chance of their length value falling between a frame. This doesn't really help anything with video since a frame is a discrete point in time, and only led to confusion while navigating the timeline. --- app/widget/timelinewidget/tool/import.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index 64ff38f40..42ed21e82 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -117,8 +117,14 @@ void TimelineWidget::ImportTool::DragEnter(TimelineViewMouseEvent *event) footage_duration = Config::Current()["DefaultStillLength"].value(); } else { // Use duration from file - footage_duration = rational(stream->timebase().numerator() * stream->duration(), - stream->timebase().denominator()); + int64_t stream_duration = stream->duration(); + + // Rescale to timeline timebase + stream_duration = qCeil(static_cast(stream_duration) * stream->timebase().toDouble() / parent()->timebase_dbl()); + + // Convert to rational time + footage_duration = rational(parent()->timebase().numerator() * stream_duration, + parent()->timebase().denominator()); } ghost->SetIn(ghost_start);