Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Merge main into #1043 (commands.rs, imports)

Brandon Thomas5f0dd80169d8
diff --cc crates/engine/src/commands.rs
index 49b6bcdf3,f6b9be6d9..610b7f5f4
--- a/crates/engine/src/commands.rs
+++ b/crates/engine/src/commands.rs
@@@ -243,14 -251,15 +255,23 @@@ pub(crate) fn time_p_at(p: &Value, pref
None
}
+/// In/Out / split time on the Source monitor: explicit `time`/`frame`/`seconds`/`timecode`, else the Source playhead.
+pub(crate) fn source_mark_time(s: &Session, p: &Value, item: ItemId) -> Tick {
+ let view = crate::clip_ops::source_view(s, item);
+ let rate = view.as_ref().map(|v| v.rate).unwrap_or_else(|| s.project.item(item).map(|i| i.frame_rate()).unwrap_or_else(|| s.sequence_rate()));
+ let df = s.project.sequence(item).map(|q| q.settings.drop_frame).unwrap_or(false);
+ time_p_at(p, "", rate, df, s.state.source_playhead).unwrap_or(s.state.source_playhead)
+}
+
+ /// Sequence time from params. Times before 0 are unreachable in the GUI and cut off on export.
+ pub(crate) fn sequence_time_p(s: &Session, p: &Value, prefix: &str, cmd: &str) -> Result<Option<Tick>> {
+ let Some(t) = time_p(s, p, prefix) else { return Ok(None) };
+ if t < Tick::ZERO {
+ return Err(bad(cmd, "time must not be negative"));
+ }
+ Ok(Some(t))
+ }
+
pub(crate) fn clip_p(p: &Value, k: &str) -> Option<ClipId> {
u64_p(p, k).map(ClipId)
}
diff --cc crates/engine/src/sequence_tools.rs
index 608d70049,ec8cbecba..92ef23200
--- a/crates/engine/src/sequence_tools.rs
+++ b/crates/engine/src/sequence_tools.rs
@@@ -31,7 -31,7 +31,7 @@@ use filmcraft_project::{AudioChannels,
use filmcraft_time::{Tick, TimeRange};
use serde_json::{Value, json};
- use crate::commands::{CommandSpec, always, bad, bool_p, clips_p, has_seq, source_mark_time, str_p, time_p, track_p, with_links};
-use crate::commands::{CommandSpec, always, bad, bool_p, clips_p, has_seq, marker_color_p, sequence_time_p, str_p, time_p, track_p, with_links};
++use crate::commands::{CommandSpec, always, bad, bool_p, clips_p, has_seq, marker_color_p, sequence_time_p, source_mark_time, str_p, time_p, track_p, with_links};
use crate::{EngineError, Result, Session};
type Run = fn(&mut Session, &Value) -> Result<Value>;