Skip to content

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

interchange: FCP7 XML import reports a clip item whose file is not defined

punkhop4aa3f79953ab
diff --git a/crates/interchange/README.md b/crates/interchange/README.md
index 75e474d96..f8dbd84c1 100644
--- a/crates/interchange/README.md
+++ b/crates/interchange/README.md
@@ -47,7 +47,7 @@ none of the exports brings one back. Each such clip is named in the export `Repo
| Format | Written as | On import into FilmCraft |
|---|---|---|
-| FCP7 XML | a clip item without media (its layers as FilmCraft filter ids) | not read back |
+| FCP7 XML | a clip item without media (its layers as FilmCraft filter ids) | not read back; the import report names the skipped clip item |
| 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 |
@@ -65,7 +65,7 @@ OMF carries no video at all.
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.
+ matches the report; the FCP7 XML import names a clip item whose file is not defined.
- `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/fcp7.rs b/crates/interchange/src/fcp7.rs
index b7bd91a9e..c04cd66db 100644
--- a/crates/interchange/src/fcp7.rs
+++ b/crates/interchange/src/fcp7.rs
@@ -380,7 +380,13 @@ impl<'a, 'i> Imp<'a, 'i, '_> {
let label = if name.is_empty() { g.label() } else { name.clone() };
self.b.generator_media(&key, &label, g, &spec, None)
} else if let Some(f) = child(c, "file") {
- self.file(f, Some(&name), None)?
+ match self.file(f, Some(&name), None) {
+ Some(item) => item,
+ None => {
+ self.report.warn(format!("clip \"{name}\" refers to a file the document does not define; skipped"));
+ return None;
+ }
+ }
} else if let Some(s) = child(c, "sequence") {
self.sequence(s, None)?
} else {
diff --git a/crates/interchange/tests/uncarried_clips.rs b/crates/interchange/tests/uncarried_clips.rs
index b3443653f..2f0902e26 100644
--- a/crates/interchange/tests/uncarried_clips.rs
+++ b/crates/interchange/tests/uncarried_clips.rs
@@ -108,3 +108,39 @@ fn the_reports_match_what_an_import_gives_back() {
assert_eq!(names.iter().any(|n| n.starts_with("Opening")), format == Format::Otio, "{format:?}: {names:?}");
}
}
+
+/// The FCP7 XML importer dropped a clip item whose `<file>` reference has no definition (which is
+/// how the export writes a title) without a word: the import report names it.
+#[test]
+fn fcp7_import_reports_a_clip_item_whose_file_is_not_defined() {
+ let (p, s) = project_with_a_title();
+ let (bytes, _) = export_report(&p, s, Format::Fcp7Xml);
+ let (imported, report) = import(&bytes, Format::Fcp7Xml, None).unwrap();
+ for name in ["Opening \"line\"", "Grade"] {
+ let line = format!("clip \"{name}\" refers to a file the document does not define; skipped");
+ assert_eq!(report.warnings().filter(|e| e.message == line).count(), 1, "{report}");
+ }
+ let seq = imported.project.sequence(only_seq(&imported)).unwrap();
+ let names: Vec<&str> = seq.video_tracks.iter().flat_map(|t| &t.items).map(|c| c.name.as_str()).collect();
+ assert_eq!(names, ["a.mov"], "the clip with media is imported as before");
+ // a hand-written reference to a file id that is never defined
+ let doc = r#"<?xml version="1.0" encoding="UTF-8"?>
+<xmeml version="4"><sequence id="s"><name>Cut</name><duration>48</duration><rate><timebase>24</timebase><ntsc>FALSE</ntsc></rate>
+<media><video><track>
+ <clipitem id="c1"><name>ghost</name><start>0</start><end>24</end><in>0</in><out>24</out><file id="nowhere"/></clipitem>
+ <clipitem id="c2"><name>real</name><start>24</start><end>48</end><in>0</in><out>24</out><file id="f1"><name>real.mov</name><pathurl>real.mov</pathurl></file></clipitem>
+</track></video></media></sequence></xmeml>"#;
+ let (imported, report) = import(doc.as_bytes(), Format::Fcp7Xml, None).unwrap();
+ assert!(report.mentions("clip \"ghost\" refers to a file the document does not define; skipped"), "{report}");
+ assert!(!report.mentions("\"real\""), "{report}");
+ assert_eq!(imported.project.sequence(only_seq(&imported)).unwrap().video_tracks[0].items.len(), 1);
+ // a document whose files are all defined says nothing of the kind
+ let mut plain = Project::new("Plain");
+ let s = sequence(&mut plain, "Cut", RATE, false);
+ let a = media(&mut plain, "/m/a.mov", true, true, RATE);
+ clip(&mut plain, s, TrackKind::Video, 0, a, 0, 48, 0);
+ clip(&mut plain, s, TrackKind::Video, 0, a, 48, 24, 0);
+ let (bytes, _) = export_report(&plain, s, Format::Fcp7Xml);
+ let (_, report) = import(&bytes, Format::Fcp7Xml, None).unwrap();
+ assert!(!report.mentions("does not define"), "{report}");
+}