FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
#918: keep fade-out on the clip end after Speed/Duration
Vikram Bhaskarandf282bcdc12d
diff --git a/crates/edit/src/lib.rs b/crates/edit/src/lib.rsindex bb4e6415b..2f671f0e4 100644--- a/crates/edit/src/lib.rs+++ b/crates/edit/src/lib.rs@@ -1061,6 +1061,7 @@ pub fn set_speed_group(seq: &mut Sequence, clips: &[ClipId], speed: f64, reverseit.speed = speed;it.reverse = reverse;it.duration = new_dur;+ fades_follow_edges(work.track_mut(tid).ok_or(EditError::NoTrack(tid))?, *clip);origins.push((tid, old_end, delta));}let main_from = origins.first().map(|o| o.1).unwrap_or_default();diff --git a/crates/edit/src/tests.rs b/crates/edit/src/tests.rsindex 9272a94da..80e8846a1 100644--- a/crates/edit/src/tests.rs+++ b/crates/edit/src/tests.rs@@ -492,6 +492,30 @@ fn fades_follow_a_regular_trim() {fx.seq.check().unwrap();}+#[test]+fn fades_follow_a_non_ripple_speed_change() {+ // #918: faster without ripple shortens the clip; the fade-out stays on the new out point.+ let mut fx = Fx::new();+ let v1 = fx.v(0);+ let a = fx.put(v1, 0, 100, 0);+ fx.seq.track_mut(v1).unwrap().transitions = vec![Transition {+ id: TransitionId(1),+ effect: filmcraft_project::find_effect("cross_dissolve").unwrap().instance(),+ start: f(90),+ duration: f(10),+ from: Some(a),+ to: None,+ align: Default::default(),+ reverse: false,+ }];+ let mut n = fx.next;+ set_speed(&mut fx.seq, a, 2.0, false, false, &mut Fx::ctx(&mut n)).unwrap();+ let tr = &fx.seq.track(v1).unwrap().transitions[0];+ assert_eq!(fx.spans(v1), vec![(0, 50)]);+ assert_eq!((tr.start, tr.duration), (f(40), f(10)));+ fx.seq.check().unwrap();+}+#[test]fn transitions_travel_with_moved_clips() {// V1: a [0,10) fading in, b [10,20), c [20,30); b→c crossfade, c fading outdiff --git a/crates/engine/src/clip_ops_tests.rs b/crates/engine/src/clip_ops_tests.rsindex 68eb470f1..6fbb93ddf 100644--- a/crates/engine/src/clip_ops_tests.rs+++ b/crates/engine/src/clip_ops_tests.rs@@ -868,6 +868,29 @@ fn color_matte_color_changes_and_undoes() {assert!(s.execute("project.matteColor", json!({"item": matte, "color": "green"})).is_err());}+/// #918: non-ripple Speed/Duration 200% halves a 100-frame clip; a 10-frame fade-out must+/// move from frames 90–100 to 40–50 (the new clip end), not stay past the clip.+#[test]+fn speed_duration_moves_fade_out_to_the_new_clip_end() {+ let mut s = Session::default();+ s.execute("file.newSequence", json!({"name": "Speed fade", "video": 1, "audio": 0})).unwrap();+ let rate = s.sequence_rate();+ let seconds = rate.tick_of(100).seconds();+ let matte = s.execute("file.newColorMatte", json!({"color": "#ff0000", "seconds": seconds})).unwrap()["item"].as_u64().unwrap();+ let c = s.execute("timeline.place", json!({"item": matte, "track": "V1", "seconds": 0.0})).unwrap()["clips"][0].as_u64().unwrap();+ select(&mut s, &[c]);+ s.execute("sequence.applyVideoTransition", json!({"edge": "out", "frames": 10})).unwrap();+ let before = s.active_sequence().unwrap().video_tracks[0].transitions[0].clone();+ assert_eq!((rate.frame_at(before.start), rate.frame_at(before.end())), (90, 100));+ s.execute("clip.speedDuration", json!({"speed": 200})).unwrap();+ let it = clip(&s, c);+ let fade = &s.active_sequence().unwrap().video_tracks[0].transitions[0];+ assert_eq!((rate.frame_at(it.start), rate.frame_at(it.end())), (0, 50));+ assert_eq!((rate.frame_at(fade.start), rate.frame_at(fade.end())), (40, 50));+ assert_eq!(fade.from, Some(filmcraft_project::ClipId(c)));+ assert_eq!(fade.to, None);+}+/// A damaged project whose subclip is its own parent (#66): `media_duration` followed the chain/// without a bound and overflowed the stack. It gives up after a few hops now.#[test]