forge
Explore
Log in

Don't you dare go Hollow

🐛 An image sequence places at its own frame count, not the project's still length, and edit replies name it (sequence)

Browse files at this commit

f150749ea02bbc940e3d6d02094dc20d11765e6cAhmet Kaan GümüşParent: a888db9
crates/engine/src/editkeys.rsmodified+1 -1
@@ -274,7 +274,7 @@ pub fn matched_source(
274274 true => clip.out_frame.saturating_sub(1).saturating_sub(from_in),
275275 false => clip.in_frame + from_in,
276276 };
277- let secs = if crate::is_image(&src.path) { 0. } else { f64::from(at) / fps };
277+ let secs = if crate::is_still(&src.path) { 0. } else { f64::from(at) / fps };
278278 Some((src.path.clone(), src.audio_stream, secs))
279279 }
280280
crates/engine/src/lib.rsmodified+4 -0
@@ -169,6 +169,10 @@ pub fn is_image(path: &std::path::Path) -> bool {
169169 })
170170 }
171171
172+pub fn is_still(path: &std::path::Path) -> bool {
173+ is_image(path) && sequence::Run::parse(path).is_none()
174+}
175+
172176 /// Whether a source's file is there to read: a real file, or a generator, which has none to miss.
173177 pub fn source_present(path: &std::path::Path) -> bool {
174178 generate::is_generated(path)
crates/engine/src/playback.rsmodified+1 -0
@@ -5918,6 +5918,7 @@ impl PlaybackSession {
59185918 start: 0,
59195919 in_frame: 0,
59205920 out_frame: match image {
5921+ true if !crate::is_still(path) => frames,
59215922 true => place_frames(frames, self.meta.frame_rate, self.project.still_secs()),
59225923 false => sound_held_frames(path, stream, frames, self.meta.frame_rate),
59235924 },
crates/engine/src/project.rsmodified+1 -1
@@ -9686,7 +9686,7 @@ impl Project {
96869686 fn is_still(&self, clip: &Clip) -> bool {
96879687 self.sources
96889688 .get(clip.source)
9689- .is_some_and(|s| crate::is_image(&s.path))
9689+ .is_some_and(|s| crate::is_still(&s.path))
96909690 }
96919691
96929692 /// The placements that move as one with the one at `idx` of `lane` --
crates/mcp/src/tools/edit.rsmodified+20 -7
@@ -1310,9 +1310,13 @@ fn place_op(
13101310 }
13111311 // `length` sets how long the still shows; omitted, it is the project's still length.
13121312 let asked = length(op, "length", fps)?;
1313+ let run = (!engine::is_still(&path)).then(|| s.file_frames(&path));
13131314 let len = match asked {
1314- None => (still * fps).ceil().max(1.0) as u32,
1315+ None => run.unwrap_or_else(|| (still * fps).ceil().max(1.0) as u32),
13151316 Some(0) => return Err(format!("place src:{n}: a still's length must be more than 0")),
1317+ Some(l) if run.is_some_and(|r| l > r) => {
1318+ return Err(format!("place src:{n}: length {} is past the sequence's {}", secs_text(l, fps), secs_text(run.unwrap_or(0), fps)))
1319+ }
13161320 Some(l) if f64::from(l) > STILL_MAX_SECS * fps => {
13171321 return Err(format!(
13181322 "place src:{n}: length {} is past the {STILL_MAX_SECS:.0} s a still may run",
@@ -1358,7 +1362,8 @@ fn place_op(
13581362 }
13591363 }
13601364 let touched = clips_of_source_at(s, n, at);
1361- let mut text = format!("{verb} src:{n} (still) @{at}f");
1365+ let kind = if run.is_some() { "sequence" } else { "still" };
1366+ let mut text = format!("{verb} src:{n} ({kind}) @{at}f");
13621367 if asked.is_some() {
13631368 text.push_str(&format!(" for {}", secs_text(len, fps)));
13641369 }
@@ -1646,7 +1651,11 @@ fn op_three_point(s: &mut PlaybackSession, kind: SourceEdit, op: &Value, fps: f6
16461651 "src:{n} is a still image, which takes no in/out: give `to` or `length` for how long it shows (default {still:.1} s, the project's still length, up to {STILL_MAX_SECS:.0} s)"
16471652 ));
16481653 }
1649- let len = dur.unwrap_or_else(|| (still * fps).ceil().max(1.0) as u32);
1654+ let run = (!engine::is_still(&path)).then(|| s.file_frames(&path));
1655+ let len = dur.or(run).unwrap_or_else(|| (still * fps).ceil().max(1.0) as u32);
1656+ if run.is_some_and(|r| len > r) {
1657+ return Err(format!("{verb} src:{n}: {} is past the sequence's {}", secs_text(len, fps), secs_text(run.unwrap_or(0), fps)));
1658+ }
16501659 if f64::from(len) > STILL_MAX_SECS * fps {
16511660 return Err(format!("{verb} src:{n}: {} is past the {STILL_MAX_SECS:.0} s a still may run", secs_text(len, fps)));
16521661 }
@@ -1698,7 +1707,11 @@ fn op_three_point(s: &mut PlaybackSession, kind: SourceEdit, op: &Value, fps: f6
16981707 let (l_in, l_out) = landed_span(s, &touched, n).unwrap_or((in_f, out_f));
16991708 let len = s.lane_clips(touched[0].0).iter().find(|c| c.start == at && c.source == n).map_or(out_f - in_f, |c| c.frames());
17001709 let names: Vec<String> = lanes.iter().map(|&l| parse::lane_name(l)).collect();
1701- let shown = if still { "(still)".to_string() } else { Base::of(s, &path).span(l_in, l_out) };
1710+ let shown = match (still, engine::is_still(&path)) {
1711+ (true, true) => "(still)".to_string(),
1712+ (true, false) => "(sequence)".to_string(),
1713+ _ => Base::of(s, &path).span(l_in, l_out),
1714+ };
17021715 let mut text = format!(
17031716 "{verb} src:{n} {shown} at timeline {at}f ({}) on {} for {}{note}",
17041717 secs_text(at, fps),
@@ -6382,9 +6395,9 @@ fn op_replace(s: &mut PlaybackSession, op: &Value, fps: f64) -> Result<Done, Str
63826395 let n = source_arg(s, op)?;
63836396 check_unlocked(s, &take_of(s, lane, idx).iter().map(|&(l, _)| l).collect::<Vec<_>>())?;
63846397 let path: PathBuf = s.sources()[n].path.clone();
6385- let still = engine::is_image(&path);
6386- let picture = still || engine::probe_media(&path).video.is_some();
6387- let sound = !still
6398+ let still = engine::is_still(&path);
6399+ let picture = engine::is_image(&path) || engine::probe_media(&path).video.is_some();
6400+ let sound = !engine::is_image(&path)
63886401 && !AudioSession::probe_streams(&path).map_err(|e| format!("src:{n}: cannot read its sound: {e}"))?.is_empty();
63896402 let total = source_frames(s, n, Some(lane), fps);
63906403 let (in_f, note) = if still {
crates/mcp/src/tools/media.rsmodified+6 -3
@@ -2573,7 +2573,7 @@ mod agreement_tests {
25732573 quiet();
25742574 let td = TestDir::new("png-run-import");
25752575 let still = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/../engine/tests/fixtures/fuzz/still.png")).expect("read the still");
2576- for k in 1..=10 {
2576+ for k in 1..=200 {
25772577 std::fs::write(td.path().join(format!("frame_{k:04}.png")), &still).expect("write a frame");
25782578 }
25792579 let mut server = Server::new();
@@ -2581,8 +2581,11 @@ mod agreement_tests {
25812581 let one = td.path().join("frame_0004.png");
25822582 let r = import(&mut server, &json!({"paths": [one.display().to_string()]}));
25832583 assert!(!r.is_error, "{}", r.text);
2584- assert!(r.text.contains("image sequence, 10 frames"), "{}", r.text);
2585- assert!(r.text.contains("frame_[0001-0010].png"), "{}", r.text);
2584+ assert!(r.text.contains("image sequence, 200 frames"), "{}", r.text);
2585+ assert!(r.text.contains("frame_[0001-0200].png"), "{}", r.text);
2586+ let r = super::super::edit::run_edit(&mut server, &json!({"ops": [{"op": "append", "source": "src:0"}]}));
2587+ assert!(!r.is_error && r.text.contains("(sequence)"), "{}", r.text);
2588+ assert_eq!(server.session.as_ref().unwrap().lane_clips(engine::project::Lane::V1)[0].frames(), 200, "{}", r.text);
25862589 }
25872590
25882591 #[test]