Skip to content

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

interchange: an export names every title it cannot carry

punkhop6899f15e518d
diff --git a/crates/engine/src/graphics_tests.rs b/crates/engine/src/graphics_tests.rs
index 64bda761b..10ae78527 100644
--- a/crates/engine/src/graphics_tests.rs
+++ b/crates/engine/src/graphics_tests.rs
@@ -129,6 +129,33 @@ fn graphic_renders_in_the_program_and_survives_save() {
assert!(fonts.as_array().unwrap().iter().any(|f| f["family"] == "Inter"));
}
+/// `file.exportInterchange` wrote a title out of the document without saying so: the command's
+/// report names every graphic clip a format cannot carry.
+#[test]
+fn interchange_export_reports_the_title_it_cannot_carry() {
+ let d = std::env::temp_dir().join(format!("fc-title-report-{}", std::process::id()));
+ std::fs::create_dir_all(&d).unwrap();
+ let mut s = demo();
+ let r = s.execute("graphics.newText", json!({"text": "Opening line", "time": 0, "seconds": 2.0})).unwrap();
+ let clip = ClipId(r["clip"].as_u64().unwrap());
+ let (track, it) = s.active_sequence().unwrap().find_item(clip).map(|(t, i)| (t, i.clone())).unwrap();
+ let frame = s.sequence_rate().frame_at(it.start);
+ let want = format!("graphic clip \"{}\" at frame {frame}", it.name);
+ for format in ["xml", "fcpxml", "otio", "aaf"] {
+ let path = d.join(format!("cut.{format}")).to_string_lossy().to_string();
+ let r = s.execute("file.exportInterchange", json!({"format": format, "path": path})).unwrap();
+ let named = r["report"].as_array().unwrap().iter().filter(|l| l.as_str().is_some_and(|l| l.starts_with(&want))).count();
+ assert_eq!(named, 1, "{format}: {}", r["report"]);
+ }
+ // an EDL holds one video track: the report names the title when its track is the one written
+ let q = s.active_sequence().unwrap();
+ assert_ne!(q.video_tracks[0].id, track, "the title sits above the footage");
+ let path = d.join("cut.edl").to_string_lossy().to_string();
+ let r = s.execute("file.exportInterchange", json!({"format": "edl", "path": path})).unwrap();
+ assert!(r["report"].to_string().contains("one video track"), "{}", r["report"]);
+ let _ = std::fs::remove_dir_all(&d);
+}
+
fn quad_box(s: &mut Session, clip: u64, layer: usize) -> [f64; 4] {
let l = s.execute("graphics.list", json!({"clip": clip})).unwrap();
let q = l["layers"][layer]["quad"].as_array().unwrap().clone();
diff --git a/crates/interchange/README.md b/crates/interchange/README.md
index 681653dae..75e474d96 100644
--- a/crates/interchange/README.md
+++ b/crates/interchange/README.md
@@ -39,6 +39,22 @@ Not represented: speed changes and frame holds (exported at 100 % with a report
sequences, graphics and synthetic media (gaps), video effects other than transitions, clip
markers (written to the master mob, so they come back as media markers), OMF video and markers.
+## Graphics and adjustment layers
+
+No format here has an equivalent of a FilmCraft graphic (title) clip or an adjustment layer, and
+none of the exports brings one back. Each such clip is named in the export `Report` as a warning
+(`graphic clip "Title" at frame 48 …`, one line per clip), with what was written instead:
+
+| Format | Written as | On import into FilmCraft |
+|---|---|---|
+| FCP7 XML | a clip item without media (its layers as FilmCraft filter ids) | not read back |
+| FCPXML | a clip without media | not read back |
+| OTIO | a clip with a `MissingReference` (effects in the `filmcraft` metadata) | offline media |
+| EDL | an ordinary event with the reel the reel mode gives | an ordinary clip |
+| AAF | a gap | nothing |
+
+OMF carries no video at all.
+
## Tests
- `tests/aaf_omf.rs`: AAF round trips at 25, 29.97 DF, 23.976 and 59.94 DF (clips, gaps,
@@ -47,6 +63,9 @@ markers (written to the master mob, so they come back as media markers), OMF vid
(sample data and source offsets); separate consolidated files with a video mixdown; OMF round
trips with embedded audio, separate AIFF files and breakout; empty sequences; truncation and
random corruption never panic.
+- `tests/uncarried_clips.rs`: every format's export report names each graphic clip and adjustment
+ layer once, as a warning; a sequence without them reports nothing; what a re-import gives back
+ matches the report.
- `src/aaf/tests.rs`: written files checked against the required properties of every class
written (Header, Identification, Mobs, slots, components, descriptors), weak references
resolving into the dictionary, source clips resolving to mobs and slots, the Edit Protocol
diff --git a/crates/interchange/src/common.rs b/crates/interchange/src/common.rs
index 170724a9e..1988ffa78 100644
--- a/crates/interchange/src/common.rs
+++ b/crates/interchange/src/common.rs
@@ -301,6 +301,18 @@ pub(crate) fn base_item(p: &Project, id: ItemId) -> ItemId {
}
}
+/// How an export report names a clip whose source is a graphic (title) or an adjustment layer,
+/// which most interchange formats cannot carry: `graphic clip "Title" at frame 48`. `None` for
+/// every other clip. A lost title must be named, not folded into a count.
+pub(crate) fn uncarried_clip(p: &Project, c: &TrackItem, rate: FrameRate) -> Option<String> {
+ let what = match &p.item(c.item)?.kind {
+ ItemKind::Graphic { .. } => "graphic clip",
+ ItemKind::AdjustmentLayer { .. } => "adjustment layer",
+ _ => return None,
+ };
+ Some(format!("{what} \"{}\" at frame {}", c.name, rate.frame_at(c.start)))
+}
+
pub(crate) fn generator_of(p: &Project, id: ItemId) -> Option<&Generator> {
match &item_media(p, id)?.media {
MediaRef::Generator(g) => Some(g),
diff --git a/crates/interchange/src/comp.rs b/crates/interchange/src/comp.rs
index 4731f206f..6efb58e62 100644
--- a/crates/interchange/src/comp.rs
+++ b/crates/interchange/src/comp.rs
@@ -272,7 +272,10 @@ impl Exporter<'_> {
return None;
}
_ => {
- self.report.warn("graphics, titles and adjustment layers are not exported (left as gaps)");
+ match crate::common::uncarried_clip(self.p, c, self.seq_rate) {
+ Some(clip) => self.report.warn(format!("{clip} is not exported (left as a gap)")),
+ None => self.report.warn("graphics, titles and adjustment layers are not exported (left as gaps)"),
+ }
return None;
}
};
diff --git a/crates/interchange/src/edl.rs b/crates/interchange/src/edl.rs
index fb7b841f1..c9b3ef4a5 100644
--- a/crates/interchange/src/edl.rs
+++ b/crates/interchange/src/edl.rs
@@ -764,6 +764,9 @@ pub(crate) fn export(p: &Project, seq_id: ItemId, opts: &ExportOptions, report:
let tr_in = track.transitions.iter().find(|t| t.to == Some(it.id));
let tr_out = track.transitions.iter().find(|t| t.from == Some(it.id));
let reel = x.reel(it.item, report);
+ if let Some(clip) = crate::common::uncarried_clip(p, it, rate) {
+ report.warn(format!("{clip} cannot be represented in an EDL: it is written as an ordinary event (reel {reel})"));
+ }
let mut rec0 = it.start;
let mut rec1 = it.end();
let mut src0 = it.source_in;
diff --git a/crates/interchange/src/fcp7.rs b/crates/interchange/src/fcp7.rs
index dadd1a391..b7bd91a9e 100644
--- a/crates/interchange/src/fcp7.rs
+++ b/crates/interchange/src/fcp7.rs
@@ -908,6 +908,10 @@ impl Exp<'_, '_> {
if !on_frame(rate, c.start) || !on_frame(rate, c.duration) {
self.report.warn("sub-frame clip positions were rounded to frames");
}
+ if let Some(clip) = crate::common::uncarried_clip(self.p, c, rate) {
+ self.report
+ .warn(format!("{clip} has no Final Cut Pro 7 XML equivalent: it is written as a clip item without media and is not read back on import"));
+ }
let base = base_item(self.p, c.item);
let generator = crate::common::generator_of(self.p, base).cloned();
let is_seq = matches!(self.p.item(base).map(|i| &i.kind), Some(ItemKind::Sequence(_)));
diff --git a/crates/interchange/src/fcpxml.rs b/crates/interchange/src/fcpxml.rs
index ad8b7bbed..623afb08d 100644
--- a/crates/interchange/src/fcpxml.rs
+++ b/crates/interchange/src/fcpxml.rs
@@ -972,7 +972,13 @@ impl Exp<'_, '_> {
let origin = self.p.sequence(base).map(|s| s.settings.frame_rate.tick_of(s.start_timecode)).unwrap_or(Tick::ZERO);
("ref-clip", r, origin)
} else {
- let r = self.asset(base, rate);
+ let r = match crate::common::uncarried_clip(self.p, it, rate) {
+ Some(clip) => {
+ self.report.warn(format!("{clip} is not supported in FCPXML: it is written as a clip without media and is not read back on import"));
+ String::new()
+ }
+ None => self.asset(base, rate),
+ };
let m = item_media(self.p, base);
let mrate = m.and_then(|m| m.info.video.as_ref().map(|v| v.frame_rate)).unwrap_or(rate);
let st = m.and_then(|m| m.info.start_timecode).map(|f| mrate.tick_of(f)).unwrap_or(Tick::ZERO);
diff --git a/crates/interchange/src/otio.rs b/crates/interchange/src/otio.rs
index 6cc56dd7b..b4fabb31f 100644
--- a/crates/interchange/src/otio.rs
+++ b/crates/interchange/src/otio.rs
@@ -279,6 +279,10 @@ impl Exp<'_, '_> {
return s;
}
let _ = generator_of(self.p, base);
+ if let Some(clip) = crate::common::uncarried_clip(self.p, it, rate) {
+ self.report
+ .warn(format!("{clip} has no OTIO equivalent: it is written as a clip with a missing media reference and is read back as offline media"));
+ }
let mref = self.media_ref(base, rate);
// OTIO source times are in the reference's time (which starts at its available_range start).
let origin = item_media(self.p, base).and_then(|m| m.info.start_timecode.map(|f| m.frame_rate().tick_of(f))).unwrap_or(Tick::ZERO);
diff --git a/crates/interchange/tests/uncarried_clips.rs b/crates/interchange/tests/uncarried_clips.rs
new file mode 100644
index 000000000..b3443653f
--- /dev/null
+++ b/crates/interchange/tests/uncarried_clips.rs
@@ -0,0 +1,110 @@
+//! Graphic (title) clips and adjustment layers have no equivalent in the interchange formats. An
+//! export used to lose them without a word (FCP7 XML, OTIO, EDL) or with a line that named
+//! nothing (FCPXML, AAF): every such clip is now named in the export report.
+
+mod support;
+
+use filmcraft_interchange::{ExportOptions, Format, Report, export, import};
+use filmcraft_project::{ItemId, ItemKind, Label, ParamValue, Project, TrackKind, find_effect};
+use filmcraft_time::FrameRate;
+use support::*;
+
+const RATE: FrameRate = FrameRate::FPS_24;
+
+/// V1: a media clip (frames 0–48) and an adjustment layer (48–72); V2: a title (12–36).
+fn project_with_a_title() -> (Project, ItemId) {
+ let mut p = Project::new("Titles");
+ let s = sequence(&mut p, "Cut", RATE, false);
+ let a = media(&mut p, "/m/a.mov", true, true, RATE);
+ let graphic = p.add_item("Graphic", Label::Rose, ItemKind::Graphic { width: 1920, height: 1080, rate: RATE }, None);
+ let layer =
+ p.add_item("Adjustment Layer", Label::Iris, ItemKind::AdjustmentLayer { width: 1920, height: 1080, rate: RATE, duration: RATE.tick_of(240) }, None);
+ clip(&mut p, s, TrackKind::Video, 0, a, 0, 48, 0);
+ let adj = clip(&mut p, s, TrackKind::Video, 0, layer, 48, 24, 0);
+ let title = clip(&mut p, s, TrackKind::Video, 1, graphic, 12, 24, 0);
+ let q = p.sequence_mut(s).unwrap();
+ let (_, t) = q.find_item_mut(title).unwrap();
+ t.name = "Opening \"line\"".into();
+ let mut text = find_effect("graphic_text").unwrap().instance();
+ text.params.get_mut("text").unwrap().value = ParamValue::Text("Opening line".into());
+ t.effects.push(text);
+ q.find_item_mut(adj).unwrap().1.name = "Grade".into();
+ q.check().unwrap();
+ (p, s)
+}
+
+fn export_report(p: &Project, s: ItemId, format: Format) -> (Vec<u8>, Report) {
+ export(p, s, format, &ExportOptions::default()).unwrap_or_else(|e| panic!("{format:?}: {e}"))
+}
+
+const TITLE: &str = "graphic clip \"Opening \"line\"\" at frame 12";
+const LAYER: &str = "adjustment layer \"Grade\" at frame 48";
+
+#[test]
+fn every_format_names_the_title_and_the_adjustment_layer_it_cannot_carry() {
+ let (p, s) = project_with_a_title();
+ for format in [Format::Fcp7Xml, Format::Fcpxml, Format::Otio, Format::Aaf] {
+ let (_, report) = export_report(&p, s, format);
+ for clip in [TITLE, LAYER] {
+ let named: Vec<_> = report.warnings().filter(|e| e.message.starts_with(clip)).collect();
+ assert_eq!(named.len(), 1, "{format:?} names {clip} once, as a warning: {report}");
+ assert_eq!(named[0].count, 1);
+ }
+ }
+ // an EDL holds one video track: V1 by default (the layer), V2 when asked (the title)
+ let (_, report) = export_report(&p, s, Format::Edl);
+ assert!(report.mentions(LAYER) && !report.mentions(TITLE), "{report}");
+ let mut opts = ExportOptions::default();
+ opts.edl.video_track = Some(1);
+ let (_, report) = export(&p, s, Format::Edl, &opts).unwrap();
+ assert!(report.mentions(TITLE), "{report}");
+}
+
+#[test]
+fn two_titles_are_two_report_lines() {
+ let (mut p, s) = project_with_a_title();
+ let graphic = p.items.values().find(|i| matches!(i.kind, ItemKind::Graphic { .. })).map(|i| i.id).unwrap();
+ let second = clip(&mut p, s, TrackKind::Video, 1, graphic, 40, 10, 0);
+ p.sequence_mut(s).unwrap().find_item_mut(second).unwrap().1.name = "Closing".into();
+ for format in [Format::Fcp7Xml, Format::Fcpxml, Format::Otio, Format::Aaf] {
+ let (_, report) = export_report(&p, s, format);
+ assert!(report.mentions(TITLE) && report.mentions("graphic clip \"Closing\" at frame 40"), "{format:?}: {report}");
+ }
+}
+
+#[test]
+fn a_sequence_without_such_clips_reports_nothing_about_them() {
+ let mut p = Project::new("Plain");
+ let s = sequence(&mut p, "Cut", RATE, false);
+ let a = media(&mut p, "/m/a.mov", true, true, RATE);
+ clip(&mut p, s, TrackKind::Video, 0, a, 0, 48, 0);
+ for format in [Format::Fcp7Xml, Format::Fcpxml, Format::Otio, Format::Edl, Format::Aaf] {
+ let (_, report) = export_report(&p, s, format);
+ assert!(!report.mentions("graphic clip") && !report.mentions("adjustment layer"), "{format:?}: {report}");
+ }
+}
+
+/// What the report says happens is what happens: the written documents do not bring the title
+/// back as a graphic.
+#[test]
+fn the_reports_match_what_an_import_gives_back() {
+ let (p, s) = project_with_a_title();
+ let graphics = |q: &Project| {
+ q.sequences()
+ .filter_map(|i| i.as_sequence())
+ .flat_map(|q| q.all_tracks())
+ .flat_map(|t| &t.items)
+ .filter(|c| matches!(q.item(c.item).map(|i| &i.kind), Some(ItemKind::Graphic { .. })))
+ .count()
+ };
+ assert_eq!(graphics(&p), 1);
+ for format in [Format::Fcp7Xml, Format::Fcpxml, Format::Otio] {
+ let (bytes, _) = export_report(&p, s, format);
+ let (imported, _) = import(&bytes, format, None).unwrap_or_else(|e| panic!("{format:?}: {e}"));
+ assert_eq!(graphics(&imported.project), 0, "{format:?}");
+ let seq = only_seq(&imported);
+ let names: Vec<String> = imported.project.sequence(seq).unwrap().video_tracks.iter().flat_map(|t| &t.items).map(|c| c.name.clone()).collect();
+ // "not read back" (the XML formats) / "read back as offline media" (OTIO)
+ assert_eq!(names.iter().any(|n| n.starts_with("Opening")), format == Format::Otio, "{format:?}: {names:?}");
+ }
+}