Skip to content

Commit

Permalink
fix fade out on change image Properties > Duration
Browse files Browse the repository at this point in the history
The problem affected all simple keyframes as well.

https://forum.shotcut.org/t/rogue-frame-on-fade-to-transparent-if-
resized/46996
  • Loading branch information
ddennedy committed Jan 3, 2025
1 parent 6115164 commit 8816c55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
25 changes: 3 additions & 22 deletions src/docks/timelinedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,17 +2030,8 @@ void TimelineDock::onProducerChanged(Mlt::Producer *after)
}
after->set_in_and_out(in, out);
// Adjust filters.
int n = after->filter_count();
for (int j = 0; j < n; j++) {
QScopedPointer<Mlt::Filter> filter(after->filter(j));
if (filter && filter->is_valid() && !filter->get_int("_loader")
&& !filter->get_int(kShotcutHiddenProperty)) {
in = qMin(qRound(filter->get_in() * speedRatio), length - 1);
out = qMin(qRound(filter->get_out() * speedRatio), length - 1);
filter->set_in_and_out(in, out);
//TODO: keyframes
}
}
MLT.adjustClipFilters(*after, info->frame_in, info->frame_out, in - info->frame_in,
info->frame_out - out, 0);
resetRippleAll = false;
} else if (newServiceName == "qimage" || newServiceName == "pixbuf") {
int oldLength = info->frame_out - info->frame_in;
Expand All @@ -2059,17 +2050,7 @@ void TimelineDock::onProducerChanged(Mlt::Producer *after)
}
after->set_in_and_out(in, out);
// Adjust filters.
int n = after->filter_count();
for (int j = 0; j < n; j++) {
QScopedPointer<Mlt::Filter> filter(after->filter(j));
if (filter && filter->is_valid() && !filter->get_int("_loader")
&& !filter->get_int(kShotcutHiddenProperty)) {
in = qMin(filter->get_in(), newLength - 1);
out = qMin(filter->get_out() + lengthDelta, newLength - 1);
filter->set_in_and_out(in, out);
//TODO: keyframes
}
}
MLT.adjustClipFilters(*after, info->frame_in, info->frame_out, 0, -lengthDelta, 0);
}
} else {
after->set_in_and_out(info->frame_in, info->frame_out);
Expand Down
13 changes: 9 additions & 4 deletions src/mltcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1452,8 +1452,9 @@ void Controller::adjustFilter(Mlt::Filter *filter, int in, int out, int inDelta,
emit MAIN.serviceOutChanged(outDelta, filter);

// Update simple keyframes
if (filter->get_int(kShotcutAnimOutProperty) && meta && meta->keyframes()) {
foreach (QString name, meta->keyframes()->simpleProperties()) {
if ((filter->get_int(kShotcutAnimInProperty) || filter->get_int(kShotcutAnimOutProperty)) && meta
&& meta->keyframes()) {
for (const QString &name : meta->keyframes()->simpleProperties()) {
if (!filter->get_animation(name.toUtf8().constData())) {
// Cause a string property to be interpreted as animated value.
if (meta->keyframes()->parameter(name)->isColor())
Expand All @@ -1466,8 +1467,12 @@ void Controller::adjustFilter(Mlt::Filter *filter, int in, int out, int inDelta,
int n = animation.key_count();
if (n > 1) {
animation.set_length(filter->get_length());
animation.key_set_frame(n - 2, filter->get_length() - filter->get_int(kShotcutAnimOutProperty));
animation.key_set_frame(n - 1, filter->get_length() - 1);
if (filter->get_int(kShotcutAnimInProperty) > filter->get_length() - 1) {
animation.key_set_frame(n - 1, filter->get_length() - 1);
} else if (filter->get_int(kShotcutAnimOutProperty)) {
animation.key_set_frame(n - 2, filter->get_length() - filter->get_int(kShotcutAnimOutProperty));
animation.key_set_frame(n - 1, filter->get_length() - 1);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ void Player::onProducerOpened(bool play)
if (play || (MLT.isClip() && !MLT.isClosedClip())) {
if (m_pauseAfterOpen) {
m_pauseAfterOpen = false;
QTimer::singleShot(500, this, [=](){
QTimer::singleShot(500, this, [ = ]() {
if (MLT.producer())
pause(MLT.producer()->position());
});
Expand Down

0 comments on commit 8816c55

Please sign in to comment.