Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

Studio: export editing projects to Final Cut Pro (#61)

taavie-za5b0917de6bb
diff --git a/.changeset/final-cut-pro-export.md b/.changeset/final-cut-pro-export.md
new file mode 100644
index 0000000..06186ad
--- /dev/null
+++ b/.changeset/final-cut-pro-export.md
@@ -0,0 +1,6 @@
+---
+"openfilm": minor
+"@openfilm/desktop": minor
+---
+
+Export editing projects for Final Cut Pro as FCPXML with their media, the main picture track on the primary storyline, connected overlays and separate audio clips or mixed stems. Separate audio clips retain Studio's row grouping with an audio role per row. HTML pages render as ProRes clips with alpha; subtitles are included as editable title clips above the picture tracks with a separate SRT copy.
diff --git a/README.md b/README.md
index eda8498..d43f81c 100644
--- a/README.md
+++ b/README.md
@@ -78,8 +78,8 @@ Studio runs on your machine, in your browser: use one built on Chromium (Chrome,
and exported with, so the preview is what you export. Everything in the film can be changed: text and layers in the
picture, clips on the timeline, their place, look, volume and speed, and the subtitles. Your edits are saved to the
film's files, so the agent sees and keeps them, and you can save named versions to go back to. Export a video, a GIF,
-the sound or its stems, subtitles, stills, slides, a transparent video, or the timeline itself for Premiere Pro and
-DaVinci Resolve.
+the sound or its stems, subtitles, stills, slides, a transparent video, or the timeline itself for Final Cut Pro,
+Premiere Pro and DaVinci Resolve.
The desktop app ([apps/desktop](apps/desktop)) is Studio with a chat beside it, for Claude Code, Codex and the other
agents, or its own agent with your own key.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 74ef9e8..d3c90db 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -75,8 +75,8 @@ openfilm capture <url> <file.png> # 截取正在运行的网页(产品、网
Studio 在你的电脑上运行,在浏览器里打开。片子里的一切都能改:画面里的文字和图层,时间线上的片段,它们的位置、外观、
音量和速度,还有字幕。你的修改会保存到片子的文件里,智能体能看到并保留它们;你也可以保存带名字的版本,随时回退。
-可以导出视频、GIF、声音或分轨、字幕、静帧、幻灯片、透明背景视频,也可以把整条时间线导出给 Premiere Pro 和
-DaVinci Resolve。
+可以导出视频、GIF、声音或分轨、字幕、静帧、幻灯片、透明背景视频,也可以把整条时间线导出给
+Final Cut Pro、Premiere Pro 和 DaVinci Resolve。
桌面版([apps/desktop](apps/desktop))就是 Studio 加上一个对话窗口,可以用 Claude Code、Codex 等智能体,也可以用
它自带的智能体配上你自己的 key。
diff --git a/packages/openfilm/studio/server/exports.mjs b/packages/openfilm/studio/server/exports.mjs
index bff0f02..007ccb2 100644
--- a/packages/openfilm/studio/server/exports.mjs
+++ b/packages/openfilm/studio/server/exports.mjs
@@ -31,11 +31,12 @@
* plain transcript); refused when the film has none
* { kind: 'slides', format?: 'pptx' (default) | 'pdf', frame?, fill?, shortEdge? (default 1080), at?: number[] }
* the scene stills bound as a deck (the scene's name in the speaker notes) or a PDF, one page each
- * { kind: 'nle', format?: 'xml' (default) | 'jianying' | 'capcut', fps? (snapped to 23.976, 24, 25, 29.97, 30, 50, 59.94 or 60;
+ * { kind: 'nle', format?: 'xml' (default) | 'fcpxml' | 'jianying' | 'capcut', fps? (snapped to 23.976, 24, 25, 29.97, 30, 50, 59.94 or 60;
* default 30), audio?: 'clips' (default) | 'stems', media?: 'copy' (default) | 'link', subtitles?: boolean (default true) }
- * a folder an editing program opens (see nle.mjs): `<name>.xml` (xmeml: Premiere Pro, DaVinci Resolve), each
+ * a folder an editing program opens (see nle.mjs): `<name>.xml` (xmeml: Premiere Pro, DaVinci Resolve) or `<name>.fcpxml` (Final Cut Pro), each
* web page rendered to a ProRes 4444 with alpha in media/, footage, stills and sounds cloned there (`link`:
* pointed at where they are), the sound as clips or as mixed stems, `<name>.srt` when there are subtitles.
+ * FCPXML also includes subtitles as editable Basic Title clips above the picture tracks.
* `jianying`, `capcut`: the same timeline as a 剪映 or CapCut draft (see jianying.mjs), made in the app's drafts folder when this
* computer has one (else in the exports folder, to be moved there), its subtitles a text track
*
@@ -58,6 +59,7 @@ import { fileURLToPath } from 'node:url';
import { FilmPage, launch } from '../../src/host.mjs';
import { filmSound, kill as killProcess, mix, open } from '../../src/shared.mjs';
import { FILM_FILE, clipFade, filmHtml, fittedFade, kindOf, pictureRect, readFilmFile } from '../../src/film-doc.mjs';
+import { fcpxmlDocument } from './fcpxml.mjs';
import { NLE_FPS, nleFps, planNleTimeline, probeSource, soundStem, xmemlDocument } from './nle.mjs';
import { draftsRoot, jianyingDraft } from './jianying.mjs';
import { slidesPdf, writePptx } from './slides.mjs';
@@ -84,7 +86,7 @@ export { exportsRoot };
* @typedef {Framing & { kind: 'poster', format?: 'png' | 'jpg', shortEdge?: number, at?: number }} PosterAsk
* @typedef {{ kind: 'subtitles', format?: 'srt' | 'vtt' | 'txt' }} SubtitlesAsk
* @typedef {Framing & { kind: 'slides', format?: 'pptx' | 'pdf', shortEdge?: number, at?: number[] }} SlidesAsk
- * @typedef {{ kind: 'nle', format?: 'xml' | 'jianying' | 'capcut', fps?: number, audio?: 'clips' | 'stems', media?: 'copy' | 'link', subtitles?: boolean }} NleAsk
+ * @typedef {{ kind: 'nle', format?: 'xml' | 'fcpxml' | 'jianying' | 'capcut', fps?: number, audio?: 'clips' | 'stems', media?: 'copy' | 'link', subtitles?: boolean }} NleAsk
* @typedef {{ kind: 'project', parts?: ProjectPart[], as?: 'zip' | 'folder' }} ProjectAsk
* @typedef {typeof PROJECT_PARTS[number]} ProjectPart
* @typedef {VideoAsk | GifAsk | AudioAsk | StillsAsk | PosterAsk | SubtitlesAsk | SlidesAsk | NleAsk | ProjectAsk} ExportSpec
@@ -242,7 +244,9 @@ function baseName(project, ask) {
}
case 'stills': return `${base} stills`;
case 'poster': return `${base} poster`;
- case 'nle': return ask.format === 'jianying' || ask.format === 'capcut' ? base : `${base} · Editor XML`;
+ case 'nle':
+ if (ask.format === 'fcpxml') return `${base} · Final Cut Pro`;
+ return ask.format === 'jianying' || ask.format === 'capcut' ? base : `${base} · Editor XML`;
default: return `${base}${range}`;
}
}
@@ -302,7 +306,7 @@ function checked(/** @type {ExportAsk} */ ask) {
break;
case 'nle':
if (ask.range !== undefined) throw new ExportError('an editor gets the whole timeline: no range');
- if (ask.format !== undefined && !['xml', 'jianying', 'capcut'].includes(ask.format)) throw new ExportError('format: xml, jianying or capcut');
+ if (ask.format !== undefined && !['xml', 'fcpxml', 'jianying', 'capcut'].includes(ask.format)) throw new ExportError('format: xml, fcpxml, jianying or capcut');
if (!between(ask.fps, 1, 120)) throw new ExportError(`fps: ${NLE_FPS.join(', ')}`);
if (ask.audio !== undefined && ask.audio !== 'clips' && ask.audio !== 'stems') throw new ExportError('audio: clips or stems');
if (ask.media !== undefined && ask.media !== 'copy' && ask.media !== 'link') throw new ExportError('media: copy or link');
@@ -1060,13 +1064,14 @@ export function createExports({ onChange = () => {}, captions = subtitlesForExpo
}
/**
- * The timeline for an editing program: a folder with the xmeml, the media it points at, and the subtitles as SRT
+ * The timeline for an editing program: a folder with the XML, the media it points at, and the subtitles as SRT
* (see nle.mjs), or a 剪映 or CapCut draft (jianying.mjs) in the app's drafts folder. Made in a hidden folder beside it and moved
* into place when whole.
* @param {ExportJob} job @param {string} root @param {string} out @param {AbortSignal} signal
*/
async function exportNle(job, root, out, signal) {
const ask = /** @type {NleAsk} */ (job.ask);
+ const fcp = ask.format === 'fcpxml';
const app = ask.format === 'jianying' || ask.format === 'capcut' ? ask.format : null;
/* a draft goes where its app lists its drafts, when the app is on this computer */
const dir = (app && drafts(app)) || out;
@@ -1079,6 +1084,10 @@ export function createExports({ onChange = () => {}, captions = subtitlesForExpo
: { stage: await stageOf(root), tracks: [{ clips: [{ src: 'index.html', id: title }] }] };
/* a source out of the project fails the export before anything is drawn */
for (const track of doc.tracks) for (const row of track.clips) clipPath(root, row.src);
+ const { cues } = ask.subtitles === false ? { cues: [] } : await subtitlesOf(root).catch((error) => {
+ if (fcp) throw error;
+ return { cues: [] };
+ });
const scratch = join(root, '.film', 'cache', 'export', `nle-${randomBytes(4).toString('hex')}`);
const final = freeFile(dir, baseName(job.name, ask), '');
const staging = join(dir, `.${basename(final)}.partial-${job.id}`);
@@ -1136,7 +1145,7 @@ export function createExports({ onChange = () => {}, captions = subtitlesForExpo
const f = await factsOf(path);
if (f.hasAudio) {
sounds.push({ id: row.id, src: row.src, path, at: c.at, from: c.from, to: c.to, speed: c.speed, volume,
- enabled: heard, role: soundStem(row.src), facts: f, ...(kind === 'video' ? { picture: row.id } : {}), ...(fade ? { fade } : {}) });
+ enabled: heard, role: soundStem(row.src), track: ti, facts: f, ...(kind === 'video' ? { picture: row.id } : {}), ...(fade ? { fade } : {}) });
}
}
}
@@ -1162,7 +1171,8 @@ export function createExports({ onChange = () => {}, captions = subtitlesForExpo
}
const timeline = planNleTimeline({ stage: doc.stage, duration: duration || 0.001, pictures, sounds },
- { title, fps, audio: mode, media: ask.media ?? 'copy', mediaDir: join(final, 'media'), stems: [...stems.keys()] });
+ { title, fps, audio: mode, media: ask.media ?? 'copy', mediaDir: join(final, 'media'), stems: [...stems.keys()],
+ audioTracks: fcp ? 'source' : 'roles' });
const staged = (/** @type {import('./nle.mjs').NleFile} */ f) => join(staging, 'media', basename(f.path));
/* each web page (and each picture Basic Motion can't place) drawn alone, full frame, with alpha */
@@ -1219,7 +1229,6 @@ export function createExports({ onChange = () => {}, captions = subtitlesForExpo
}
update(job, { phase: 'finishing', progress: 0.98 });
- const cues = ask.subtitles !== false ? (await subtitlesOf(root).catch(() => ({ cues: [] }))).cues : [];
if (app) {
/* the app on Windows reads draft_content.json, on a Mac draft_info.json: the same draft in both */
const draft = jianyingDraft(timeline, { app, name: basename(final), folder: final, root: dir, cues });
@@ -1230,13 +1239,14 @@ export function createExports({ onChange = () => {}, captions = subtitlesForExpo
} else {
const srt = filmSubtitleSrt(cues);
if (srt) await writeFile(join(staging, `${title}.srt`), srt, 'utf8');
- await writeFile(join(staging, `${title}.xml`), xmemlDocument(timeline), 'utf8');
+ const xml = fcp ? fcpxmlDocument(timeline, { cues }) : xmemlDocument(timeline);
+ await writeFile(join(staging, `${title}.${fcp ? 'fcpxml' : 'xml'}`), xml, 'utf8');
}
if (signal.aborted) throw new Error('cancelled');
if (!(await readdir(join(staging, 'media'))).length) await rmdir(join(staging, 'media'));
await rename(staging, final);
const media = existsSync(join(final, 'media')) ? (await readdir(join(final, 'media'))).sort().map((n) => join(final, 'media', n)) : [];
- const first = app ? 'draft_info.json' : '.xml';
+ const first = app ? 'draft_info.json' : fcp ? '.fcpxml' : '.xml';
const top = (await readdir(final)).filter((n) => n !== 'media').sort((a, b) => Number(!a.endsWith(first)) - Number(!b.endsWith(first)) || a.localeCompare(b));
/* the XML (the draft) first: "Show in Finder" shows the first */
const outputs = [...top.map((n) => join(final, n)), ...media];
diff --git a/packages/openfilm/studio/server/exports.test.mjs b/packages/openfilm/studio/server/exports.test.mjs
index 7fa42ef..d8b9328 100644
--- a/packages/openfilm/studio/server/exports.test.mjs
+++ b/packages/openfilm/studio/server/exports.test.mjs
@@ -7,6 +7,7 @@ import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { createExports, exportCapabilities, exportsRoot, ExportError, frameBox, dimsForShortEdge, hardwareEncoder, hardwareOptions, projectFiles, projectSizes } from './exports.mjs';
import { allocateLanes, containMotion, fadeKeyframes, frameSpan, nleRate, planNleTimeline, xmemlDocument } from './nle.mjs';
+import { fcpxmlDocument } from './fcpxml.mjs';
import { pptxParts } from './slides.mjs';
import { filmSubtitleSrt, parseFilmSubtitleStyle } from './film-subtitle.mjs';
import { zipFiles } from './zip.mjs';
@@ -429,6 +430,143 @@ test('fades in the editor\'s timeline: a picture that fades is rendered; a sound
assert.match(xmemlDocument(timeline), /<parameterid>level<\/parameterid>[\s\S]*<keyframe>\s*<when>0<\/when>\s*<value>0<\/value>\s*<\/keyframe>\s*<keyframe>\s*<when>13<\/when>/);
});
+test('Final Cut Pro keeps source audio rows when an effect overlaps adjacent narration clips', () => {
+ const facts = { duration: 120, hasAudio: true, channels: 2, sampleRate: 48000 };
+ const sound = (id, track, at, to) => ({ id, track, at, from: 0, to, speed: 1, volume: 1, enabled: true,
+ role: 'voice', src: `${id}.wav`, path: join(scratch, `${id}.wav`), facts });
+ const film = { stage: { w: 320, h: 180 }, duration: 120, pictures: [], sounds: [
+ sound('story-01-1', 1, 0.4, 4.98), sound('story-01-2', 1, 5.5683, 5.82),
+ sound('game-sfx-1', 2, 5.4, 0.333), sound('adventure-music', 3, 0, 120),
+ ] };
+ const opts = { title: 'Source tracks', fps: 60, audio: 'clips', media: 'copy', mediaDir: scratch };
+ const timeline = planNleTimeline(film, { ...opts, audioTracks: 'source' });
+ assert.deepEqual(timeline.audio.map((t) => t.clips.map((c) => c.name)), [
+ ['story-01-1', 'story-01-2'], ['game-sfx-1'], ['adventure-music'],
+ ]);
+ assert.deepEqual(timeline.audio.map((t) => t.sourceTrack), [1, 2, 3]);
+ const xml = fcpxmlDocument(timeline);
+ assert.match(xml, /name="story-01-1" lane="-1"[^>]*audioRole="OpenFilm A1"/);
+ assert.match(xml, /name="story-01-2" lane="-1"[^>]*audioRole="OpenFilm A1"/);
+ assert.match(xml, /name="game-sfx-1" lane="-2"[^>]*audioRole="OpenFilm A2"/);
+ assert.match(xml, /name="adventure-music" lane="-3"[^>]*audioRole="OpenFilm A3"/);
+ assert.notDeepEqual(planNleTimeline(film, opts).audio.map((t) => t.clips.map((c) => c.name)), timeline.audio.map((t) => t.clips.map((c) => c.name)), 'other editors keep their existing role grouping');
+ const overlapping = planNleTimeline({ ...film, sounds: [...film.sounds, sound('overlapping-voice', 1, 1, 2)] }, { ...opts, audioTracks: 'source' });
+ assert.equal(overlapping.audio.length, 4, 'only an overlap within a source row needs another lane');
+ assert.deepEqual(overlapping.audio.map((t) => t.sourceTrack), [1, 1, 2, 3]);
+ assert.match(fcpxmlDocument(overlapping), /name="overlapping-voice"[^>]*audioRole="OpenFilm A1"/);
+ const reversed = planNleTimeline({ ...film, sounds: [...film.sounds].reverse() }, { ...opts, audioTracks: 'source' });
+ assert.deepEqual(reversed.audio.map((t) => t.clips.map((c) => c.name)), timeline.audio.map((t) => t.clips.map((c) => c.name)));
+ const { track, ...untracked } = film.sounds[0];
+ assert.throws(() => planNleTimeline({ ...film, sounds: [untracked] }, { ...opts, audioTracks: 'source' }), /story-01-1 has no source track/);
+});
+
+test('Final Cut Pro reports unreadable subtitles before writing an incomplete export', async () => {
+ const exports = createExports({ captions: async () => { throw new Error('subtitle storage is unreadable'); } });
+ const name = 'Unreadable captions';
+ const done = await ended(exports, exports.start(project(name), { kind: 'nle', format: 'fcpxml', subtitles: true }));
+ assert.equal(done.status, 'failed');
+ assert.match(done.error, /subtitle storage is unreadable/);
+ assert.deepEqual(done.outputs, []);
+ assert.ok(!readdirSync(process.env.OPENFILM_EXPORTS).some((entry) => entry.includes(name)), 'no incomplete folder is published');
+});
+
+test('Final Cut Pro connections retain their parent and sequence positions across cuts, trims and gaps', async () => {
+ const clip = (name, start, end, from, fileId = 'picture') => ({ name, start, end, in: from, out: from + end - start, fileId, enabled: true });
+ const primary = [clip('first', 10, 35, 50), clip('second', 40, 70, 5), clip('third', 70, 100, 30)];
+ const overlays = [clip('overlay-a', 20, 60, 7), clip('overlay-b', 50, 90, 9)];
+ const across = clip('across-gap', 5, 105, 0);
+ const music = clip('music', 0, 110, 0, 'sound');
+ const voice = clip('voice', 55, 75, 12, 'sound');
+ const caption = clip('Caption & <text>\nNext line', 55, 85, 0);
+ const gapCaption = clip('Caption in gap', 37, 50, 0);
+ const expected = [...primary, ...overlays, across, music, voice, caption, gapCaption];
+ const rates = [25, 29.97];
+ const documents = rates.map((fps) => {
+ const rate = nleRate(fps);
+ const cues = [caption, gapCaption].map((c) => ({
+ text: c.name, startMs: c.start / rate.fps * 1000, durMs: (c.end - c.start) / rate.fps * 1000,
+ }));
+ return fcpxmlDocument({
+ name: 'Connected\tclips\nwith\rnames', rate, width: 1920, height: 1080, durationFrames: 110,
+ files: [
+ { id: 'picture', name: 'picture.mov', path: join(scratch, 'picture.mov'), durationFrames: 200, video: { w: 1920, h: 1080, still: false, alpha: true } },
+ { id: 'sound', name: 'sound.wav', path: join(scratch, 'sound.wav'), durationFrames: 200, audio: { channels: 2, sampleRate: 48000 } },
+ ],
+ video: [{ enabled: true, clips: primary }, { enabled: true, clips: overlays }, { enabled: true, clips: [across] }],
+ audio: [{ enabled: true, clips: [music] }, { enabled: true, clips: [voice] }],
+ }, { cues });
+ });
+ const parsed = await parseXml(documents, (doc) => {
+ const seconds = (value) => {
+ const [n, d = '1'] = (value ?? '0s').replace(/s$/, '').split('/');
+ return Number(n) / Number(d);
+ };
+ const attr = (el, name) => seconds(el.getAttribute(name));
+ const clips = [];
+ const visit = (el, parentAt, parentIn) => {
+ const at = parentAt + attr(el, 'offset') - parentIn;
+ if (el.tagName === 'asset-clip' || el.tagName === 'title') clips.push({
+ name: el.getAttribute('name'), parent: el.parentElement?.getAttribute('name'),
+ at, end: at + attr(el, 'duration'), from: attr(el, 'start'),
+ });
+ for (const child of el.children) if (['asset-clip', 'gap', 'title'].includes(child.tagName)) visit(child, at, attr(el, 'start'));
+ };
+ const spine = doc.querySelector('sequence > spine');
+ for (const child of spine.children) visit(child, 0, 0);
+ return { name: doc.querySelector('project').getAttribute('name'), primary: [...spine.children].map((el) => el.tagName === 'gap' ? 'gap' : el.getAttribute('name')), clips };
+ });
+ for (const [i, { error, found }] of parsed.entries()) {
+ assert.equal(error, null);
+ assert.equal(found.name, 'Connected\tclips\nwith\rnames');
+ assert.deepEqual(found.primary, ['gap', 'first', 'gap', 'second', 'third', 'gap']);
+ assert.equal(found.clips.length, expected.length);
+ const fps = nleRate(rates[i]).fps;
+ for (const original of expected) {
+ const actual = found.clips.find((c) => c.name === original.name);
+ assert.ok(actual, original.name);
+ assert.deepEqual([actual.at, actual.end, actual.from].map((t) => Math.round(t * fps)), [original.start, original.end, original.in], original.name);
+ }
+ const parents = Object.fromEntries(found.clips.map((c) => [c.name, c.parent]));
+ assert.equal(parents['overlay-a'], 'first');
+ assert.equal(parents['overlay-b'], 'second');
+ assert.equal(parents.voice, 'second');
+ assert.equal(parents['across-gap'], 'OpenFilm');
+ assert.equal(parents[caption.name], 'second');
+ assert.equal(parents[gapCaption.name], 'OpenFilm');
+ }
+});
+
+test('Final Cut Pro export packages FCPXML, rendered pages, audio and optional subtitle sidecars', ffmpeg, async () => {
+ for (const audio of ['clips', 'stems']) {
+ const done = await exported({ kind: 'nle', format: 'fcpxml', fps: 25, audio, subtitles: audio === 'clips' });
+ assert.match(done.out, /Tiny\.fcpxml$/);
+ for (const file of done.outputs) assert.ok(existsSync(file), file);
+ assert.equal(done.outputs.some((f) => f.endsWith('.srt')), audio === 'clips');
+ const [{ error, found }] = await parseXml([readFileSync(done.out, 'utf8')], (doc) => ({
+ version: doc.documentElement.getAttribute('version'),
+ primary: [...doc.querySelectorAll('sequence > spine > asset-clip')].map((c) => c.getAttribute('name')),
+ clips: [...doc.querySelectorAll('asset-clip')].map((c) => ({ name: c.getAttribute('name'), role: c.getAttribute('audioRole'), lane: Number(c.getAttribute('lane')), enabled: c.getAttribute('enabled'), kind: c.getAttribute('srcEnable') })),
+ media: [...doc.querySelectorAll('media-rep')].map((m) => m.getAttribute('src')),
+ formats: [...doc.querySelectorAll('format')].map((f) => f.getAttribute('frameDuration')),
+ subtitles: [...doc.querySelectorAll('title > text')].map((c) => c.textContent),
+ captions: doc.querySelectorAll('caption').length,
+ }));
+ assert.equal(error, null);
+ assert.equal(found.version, '1.10');
+ assert.deepEqual(found.subtitles, audio === 'clips' ? ['Ann:Hello there', 'And welcome'] : []);
+ assert.equal(found.captions, 0, 'subtitles use ordinary title clips instead of the fixed caption area');
+ assert.deepEqual(found.primary, ['title'], 'Studio’s main picture track becomes the primary storyline');
+ assert.equal(found.clips.filter((c) => c.kind === 'video').length, 2);
+ assert.ok(found.clips.some((c) => c.kind === 'audio' && c.lane < 0));
+ if (audio === 'clips') {
+ for (const name of ['tone', 'click']) assert.equal(found.clips.find((c) => c.name === name)?.role, 'OpenFilm A1');
+ assert.equal(found.clips.find((c) => c.name === 'bed')?.role, 'OpenFilm A2');
+ }
+ assert.ok(found.formats.every((f) => f === '1/25s'));
+ for (const url of found.media) assert.ok(existsSync(fileURLToPath(url)), url);
+ }
+});
+
test('editing software: an xmeml folder; pages rendered with alpha, footage placed, sound as clips or stems, subtitles as SRT', { ...ffmpeg, timeout: 240_000 }, async () => {
const cut = join(scratch, 'Cut');
mkdirSync(join(cut, 'footage'), { recursive: true });
diff --git a/packages/openfilm/studio/server/fcpxml.mjs b/packages/openfilm/studio/server/fcpxml.mjs
new file mode 100644
index 0000000..952980d
--- /dev/null
+++ b/packages/openfilm/studio/server/fcpxml.mjs
@@ -0,0 +1,156 @@
+// @ts-check
+import { pathToFileURL } from 'node:url';
+import { frameSpan, nleRate, xmlEscape } from './nle.mjs';
+import { filmSubtitleCuesInRange, filmSubtitleSequence, filmSubtitleText } from './film-subtitle.mjs';
+
+// FCP's bundled template identifier, resolved by FCP on import rather than by the exporting machine.
+const BASIC_TITLE = '.../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti';
+
+/**
+ * @typedef {import('./nle.mjs').NleClip} NleClip
+ * @typedef {import('./nle.mjs').NleTrack} NleTrack
+ * @typedef {{ start: number, end: number, in: number, clip?: NleClip, children: string[] }} PrimarySegment
+ * @typedef {{ enabled: boolean, lane: number, offset: number, kind: 'video' | 'audio',
+ * children?: string[], audioRole?: string }} ClipPlacement
+ */
+
+/** XML attributes must preserve whitespace in names; text nodes keep literal line breaks. @param {string} value */
+const attribute = (value) => xmlEscape(value)
+ .replaceAll('\t', '&#9;').replaceAll('\n', '&#10;').replaceAll('\r', '&#13;');
+
+/** Fill only actual gaps; Studio's lowest picture track stays on the primary storyline.
+ * @param {readonly NleClip[]} clips @param {number} durationFrames @returns {PrimarySegment[]}
+ */
+function primaryStoryline(clips, durationFrames) {
+ /** @type {PrimarySegment[]} */
+ const segments = [];
+ let cursor = 0;
+ for (const clip of [...clips].sort((a, b) => a.start - b.start)) {
+ if (clip.start < cursor) throw new Error(`primary clips overlap at frame ${clip.start}`);
+ if (clip.start > cursor) segments.push({ start: cursor, end: clip.start, in: 0, children: [] });
+ segments.push({ start: clip.start, end: clip.end, in: clip.in, clip, children: [] });
+ cursor = clip.end;
+ }
+ if (cursor < durationFrames) segments.push({ start: cursor, end: durationFrames, in: 0, children: [] });
+ return segments;
+}
+
+/** Connections use their parent's source time, rather than sequence time.
+ * @param {readonly PrimarySegment[]} primary @param {number} frame
+ */
+function connectionAt(primary, frame) {
+ const parent = primary.find((segment) => frame >= segment.start && frame < segment.end);
+ if (!parent) throw new Error(`no primary storyline segment at frame ${frame}`);
+ return { parent, offset: parent.in + frame - parent.start };
+}
+
+/**
+ * FCPXML 1.10 adapter for the shared NLE plan. Media is prepared by exports.mjs;
+ * HTML pages arrive as rendered ProRes clips. FCP roles and connection times belong here.
+ * @param {import('./nle.mjs').NleTimeline} timeline
+ * @param {{ cues?: readonly import('./film-subtitle.mjs').FilmSubtitleCue[] }} [subtitles]
+ */
+export function fcpxmlDocument(timeline, { cues = [] } = {}) {
+ const { rate, width, height } = timeline;
+ /** Exact rational seconds, including 1001-based rates, without decimal time drift. @param {number} frames @param {typeof rate} [r] */
+ const time = (frames, r = rate) => `${frames * (r.ntsc ? 1001 : 1)}/${r.timebase * (r.ntsc ? 1000 : 1)}s`;
+ const decimal = (/** @type {number} */ n) => String(Math.round(n * 1e6) / 1e6);
+ const decibels = (/** @type {number} */ gain) => `${decimal(20 * Math.log10(Math.max(0.000001, gain)))}dB`;
+ const format = (/** @type {string} */ id, /** @type {number} */ w, /** @type {number} */ h, r = rate) =>
+ ` <format id="${id}" frameDuration="${time(1, r)}" width="${w}" height="${h}" colorSpace="1-1-1 (Rec. 709)"/>`;
+ const resources = [format('sequence-format', width, height)];
+ for (const file of timeline.files) {
+ const video = file.video;
+ if (video) resources.push(format(`format-${file.id}`, video.w, video.h, video.fps ? nleRate(video.fps) : rate));
+ resources.push(
+ ` <asset id="${file.id}" name="${attribute(file.name)}" start="0s" duration="${time(file.durationFrames)}"`
+ + (video ? ` hasVideo="1" format="format-${file.id}" videoSources="1"` : '')
+ + (file.audio ? ` hasAudio="1" audioSources="1" audioChannels="${file.audio.channels}" audioRate="${file.audio.sampleRate}"` : '') + '>',
+ ` <media-rep kind="original-media" src="${attribute(pathToFileURL(file.path).href)}"/>`,
+ ' </asset>',
+ );
+ }
+ /** @param {NleClip} clip @param {ClipPlacement} placement */
+ const clipXml = (clip, { enabled, lane, offset, kind, children = [], audioRole }) => {
+ const pad = lane === 0 ? ' ' : ' ';
+ const attrs = [
+ `ref="${clip.fileId}"`, `name="${attribute(clip.name)}"`, `lane="${lane}"`,
+ `offset="${time(offset)}"`, `start="${time(clip.in)}"`, `duration="${time(clip.end - clip.start)}"`,
+ `enabled="${enabled && clip.enabled ? 1 : 0}"`, `srcEnable="${kind}"`,
+ ];
+ if (audioRole) attrs.push(`audioRole="${attribute(audioRole)}"`);
+ const lines = [`${pad}<asset-clip ${attrs.join(' ')}>`];
+ if (kind === 'video') {
+ // Disable automatic fitting: the planner's scale is relative to the source's own pixels.
+ lines.push(`${pad} <adjust-conform type="none"/>`);
+ if (clip.motion) {
+ const { scale, center } = clip.motion;
+ const position = `${decimal(center.h * width / height * 100)} ${decimal(-center.v * 100)}`;
+ lines.push(`${pad} <adjust-transform position="${position}" scale="${decimal(scale / 100)} ${decimal(scale / 100)}"/>`);
+ }
+ } else if (clip.levels?.length) {
+ lines.push(`${pad} <adjust-volume>`, `${pad} <param name="amount">`, `${pad} <keyframeAnimation>`);
+ for (const key of clip.levels) {
+ lines.push(`${pad} <keyframe time="${time(clip.in + key.when)}" value="${decibels(key.value)}" interp="linear" curve="linear"/>`);
+ }
+ lines.push(`${pad} </keyframeAnimation>`, `${pad} </param>`, `${pad} </adjust-volume>`);
+ } else if (clip.gain !== undefined) lines.push(`${pad} <adjust-volume amount="${decibels(clip.gain)}"/>`);
+ return [...lines, ...children, `${pad}</asset-clip>`];
+ };
+ const main = timeline.video[0];
+ const primary = primaryStoryline(main?.clips ?? [], timeline.durationFrames);
+ const sourceTracks = [...new Set(timeline.audio.flatMap((track) => track.sourceTrack === undefined ? [] : [track.sourceTrack]))]
+ .sort((a, b) => a - b);
+ const audioRoles = new Map(sourceTracks.map((track, i) => [track, `OpenFilm A${i + 1}`]));
+ /** @param {NleTrack} track @param {number} lane @param {'video' | 'audio'} kind */
+ const connect = (track, lane, kind) => {
+ const audioRole = kind === 'audio' && track.sourceTrack !== undefined ? audioRoles.get(track.sourceTrack) : undefined;
+ for (const clip of track.clips) {
+ const { parent, offset } = connectionAt(primary, clip.start);
+ parent.children.push(...clipXml(clip, { enabled: track.enabled, lane, offset, kind, audioRole }));
+ }
+ };
+ timeline.video.slice(1).forEach((track, i) => connect(track, i + 1, 'video'));
+ timeline.audio.forEach((track, i) => connect(track, -i - 1, 'audio'));
+ const subtitleCues = filmSubtitleCuesInRange(cues, 0, timeline.durationFrames / rate.fps * 1000);
+ const fontSize = decimal(Math.min(width, height) * 48 / 1080);
+ let titleCount = 0;
+ for (const { cue, end } of filmSubtitleSequence(subtitleCues)) {
+ const span = frameSpan(cue.startMs / 1000, end / 1000, rate);
+ if (span.end <= span.start) continue;
+ const { parent, offset } = connectionAt(primary, span.start);
+ if (titleCount === 0) resources.push(` <effect id="subtitle-title" name="Basic Title" uid="${BASIC_TITLE}"/>`);
+ const styleId = `subtitle-style-${++titleCount}`;
+ const attrs = [
+ 'ref="subtitle-title"', `name="${attribute(cue.text)}"`, `lane="${Math.max(1, timeline.video.length)}"`,
+ `offset="${time(offset)}"`, 'start="0s"', `duration="${time(span.end - span.start)}"`, 'role="titles.OpenFilm Subtitles"',
+ ];
+ // Ordinary titles stay with the picture layers; native captions use FCP's separate caption area.
+ parent.children.push(
+ ` <title ${attrs.join(' ')}>`,
+ ` <text><text-style ref="${styleId}">${xmlEscape(filmSubtitleText(cue))}</text-style></text>`,
+ ` <text-style-def id="${styleId}">`,
+ ` <text-style font="Helvetica" fontSize="${fontSize}" fontColor="1 1 1 1" strokeColor="0 0 0 1" strokeWidth="2" alignment="center"/>`,
+ ' </text-style-def>',
+ ' <adjust-transform position="0 -40"/>',
+ ' </title>',
+ );
+ }
+ const spine = primary.flatMap((segment) => {
+ if (segment.clip) return clipXml(segment.clip, {
+ enabled: main?.enabled ?? true, lane: 0, offset: segment.start, kind: 'video', children: segment.children,
+ });
+ return [
+ ` <gap name="OpenFilm" offset="${time(segment.start)}" start="0s" duration="${time(segment.end - segment.start)}">`,
+ ...segment.children, ' </gap>',
+ ];
+ });
+ return [
+ '<?xml version="1.0" encoding="UTF-8"?>', '<!DOCTYPE fcpxml>', '<fcpxml version="1.10">', ' <resources>',
+ ...resources, ' </resources>', ' <library>', ` <event name="${attribute(timeline.name)}">`,
+ ` <project name="${attribute(timeline.name)}">`,
+ ` <sequence format="sequence-format" duration="${time(timeline.durationFrames)}" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">`,
+ ' <spine>', ...spine, ' </spine>', ' </sequence>', ' </project>',
+ ' </event>', ' </library>', '</fcpxml>', '',
+ ].join('\n');
+}
diff --git a/packages/openfilm/studio/server/fcpxml.test.mjs b/packages/openfilm/studio/server/fcpxml.test.mjs
new file mode 100644
index 0000000..f4fdaaa
--- /dev/null
+++ b/packages/openfilm/studio/server/fcpxml.test.mjs
@@ -0,0 +1,140 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { existsSync, mkdtempSync, writeFileSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+import { spawnSync } from 'node:child_process';
+import { fcpxmlDocument } from './fcpxml.mjs';
+import { nleRate } from './nle.mjs';
+
+const timeline = {
+ name: 'Film <one> & "two"', rate: nleRate(29.97), width: 1920, height: 1080, durationFrames: 90,
+ files: [
+ { id: 'file-1', name: 'shot & one.mov', path: join(tmpdir(), 'openfilm-fcpxml', '电影', 'shot & one.mov'), durationFrames: 120,
+ video: { w: 960, h: 540, still: false, alpha: true, fps: 25 }, audio: { channels: 2, sampleRate: 48000 } },
+ { id: 'file-2', name: 'voice.wav', path: join(tmpdir(), 'openfilm-fcpxml', 'voice.wav'), durationFrames: 90, audio: { channels: 1, sampleRate: 44100 } },
+ { id: 'file-3', name: 'still.png', path: join(tmpdir(), 'openfilm-fcpxml', 'still.png'), durationFrames: 90, video: { w: 400, h: 200, still: true, alpha: true } },
+ ],
+ video: [
+ { enabled: true, clips: [{ name: 'footage', fileId: 'file-1', start: 15, end: 60, in: 30, out: 75, enabled: true,
+ motion: { scale: 200, center: { h: 0.25, v: -0.25 } } }] },
+ { enabled: true, clips: [{ name: 'overlay', fileId: 'file-3', start: 30, end: 90, in: 0, out: 60, enabled: true }] },
+ ],
+ audio: [
+ { enabled: true, clips: [{ name: 'sound', fileId: 'file-1', start: 15, end: 60, in: 30, out: 75, enabled: true, gain: 0.5 }] },
+ { enabled: false, clips: [{ name: 'muted', fileId: 'file-2', start: 0, end: 90, in: 0, out: 90, enabled: true,
+ levels: [{ when: 0, value: 0 }, { when: 15, value: 0.5 }, { when: 90, value: 0 }] }] },
+ ],
+};
+
+test('continuous main-track pictures occupy the primary storyline instead of connecting to a gap', () => {
+ const xml = fcpxmlDocument({ ...timeline, video: [
+ { enabled: true, clips: [
+ { name: 'first', fileId: 'file-1', start: 0, end: 30, in: 60, out: 90, enabled: true },
+ { name: 'second', fileId: 'file-1', start: 30, end: 90, in: 15, out: 75, enabled: true },
+ ] },
+ { enabled: true, clips: [{ name: 'overlay', fileId: 'file-3', start: 45, end: 75, in: 5, out: 35, enabled: true }] },
+ ], audio: [{ enabled: true, clips: [{ name: 'music', fileId: 'file-2', start: 0, end: 90, in: 0, out: 90, enabled: true }] }] });
+ assert.match(xml, /<spine>\s*<asset-clip ref="file-1" name="first" lane="0"/);
+ assert.match(xml, /name="second" lane="0" offset="30030\/30000s" start="15015\/30000s"/);
+ assert.doesNotMatch(xml, /<gap /);
+ // A connection's offset uses its parent's source timeline, not the sequence timeline.
+ assert.match(xml, /name="overlay" lane="1" offset="30030\/30000s" start="5005\/30000s"/);
+ assert.match(xml, /name="music" lane="-1" offset="60060\/30000s" start="0\/30000s" duration="90090\/30000s"/);
+});
+
+test('FCPXML keeps exact NTSC times, source trims, layering, transforms and separate sound without duplicate audio', () => {
+ const xml = fcpxmlDocument(timeline);
+ assert.match(xml, /<fcpxml version="1.10">/);
+ assert.match(xml, /frameDuration="1001\/30000s"/);
+ assert.match(xml, /id="format-file-1" frameDuration="1\/25s"/);
+ assert.match(xml, /duration="90090\/30000s" tcStart="0s"/);
+ assert.match(xml, /name="Film &lt;one&gt; &amp; &quot;two&quot;"/);
+ const sourceUrl = xml.match(/<media-rep[^>]*src="([^"]+)"/)?.[1].replaceAll('&amp;', '&');
+ assert.ok(sourceUrl);
+ assert.equal(fileURLToPath(sourceUrl), timeline.files[0].path);
+ assert.match(sourceUrl, /%E7%94%B5%E5%BD%B1\/shot%20&%20one.mov$/);
+ assert.match(xml, /lane="0" offset="15015\/30000s" start="30030\/30000s" duration="45045\/30000s" enabled="1" srcEnable="video"/);
+ assert.match(xml, /name="overlay" lane="1"/);
+ assert.match(xml, /<adjust-conform type="none"\/>/);
+ assert.match(xml, /position="44.444444 25" scale="2 2"/);
+ assert.match(xml, /name="sound" lane="-1"[^>]*srcEnable="audio"/);
+ assert.match(xml, /amount="-6.0206dB"/);
+ assert.match(xml, /name="muted" lane="-2"[^>]*enabled="0"/);
+ assert.match(xml, /<keyframe time="0\/30000s" value="-120dB"/);
+ assert.doesNotMatch(xml, /Infinity|NaN|undefined/);
+});
+
+test('only real empty intervals become primary gaps, with overlays anchored in source time', () => {
+ const xml = fcpxmlDocument(timeline);
+ assert.match(xml, /<spine>\s*<gap name="OpenFilm" offset="0\/30000s" start="0s" duration="15015\/30000s">/);
+ assert.match(xml, /<gap name="OpenFilm" offset="60060\/30000s" start="0s" duration="30030\/30000s">/);
+ assert.equal((xml.match(/<gap /g) ?? []).length, 2);
+ assert.match(xml, /name="footage" lane="0" offset="15015\/30000s" start="30030\/30000s"/);
+ assert.match(xml, /name="overlay" lane="1" offset="45045\/30000s" start="0\/30000s"/);
+ assert.doesNotMatch(xml, /duration="90090\/30000s">\s*<asset-clip ref="file-1"/);
+});
+
+test('FCPXML also writes integer-rate, audio-only timelines with a full-length primary storyline', () => {
+ const xml = fcpxmlDocument({ ...timeline, rate: nleRate(25), video: [], files: [timeline.files[1]], audio: [timeline.audio[1]] });
+ assert.match(xml, /frameDuration="1\/25s"/);
+ assert.match(xml, /<gap name="OpenFilm" offset="0\/25s" start="0s" duration="90\/25s">/);
+ assert.doesNotMatch(xml, /srcEnable="video"/);
+});
+
+test('FCPXML includes editable subtitle titles above pictures, clipped to the sequence, with escaped multiline text', () => {
+ const xml = fcpxmlDocument(timeline, { cues: [
+ { startMs: 1100, durMs: 700, text: 'Hello & <world>\n第二行', speaker: 'Ann' },
+ { startMs: 2900, durMs: 1000, text: 'End' },
+ { startMs: 4000, durMs: 500, text: 'Outside' },
+ ] });
+ assert.equal((xml.match(/<title /g) ?? []).length, 2);
+ assert.match(xml, /<effect id="subtitle-title" name="Basic Title" uid="\.\.\.\/Titles.localized\/Bumper:Opener.localized\/Basic Title.localized\/Basic Title.moti"\/>/);
+ assert.match(xml, /<title ref="subtitle-title" name="Hello[^>]*lane="2"/);
+ assert.match(xml, /role="titles.OpenFilm Subtitles"/);
+ assert.match(xml, /<text><text-style ref="subtitle-style-1">Ann:Hello &amp; &lt;world&gt;\n第二行<\/text-style><\/text>/);
+ assert.match(xml, /<adjust-transform position="0 -40"\/>/);
+ assert.deepEqual([...xml.matchAll(/<text-style-def id="([^"]+)"/g)].map((m) => m[1]), ['subtitle-style-1', 'subtitle-style-2']);
+ assert.doesNotMatch(xml, /<caption /);
+ assert.match(xml, /name="End"[^>]*duration="3003\/30000s"/);
+ assert.doesNotMatch(xml, /Outside/);
+ assert.doesNotMatch(fcpxmlDocument(timeline), /<title |<effect /);
+});
+
+test('subtitle titles on an audio-only timeline omit empty cues and end at the next subtitle', () => {
+ const xml = fcpxmlDocument({ ...timeline, rate: nleRate(25), video: [], audio: [] }, { cues: [
+ { startMs: 1000, durMs: 1000, text: 'Second' },
+ { startMs: -200, durMs: 2000, text: 'First' },
+ { startMs: 500, durMs: 100, text: ' ' },
+ { startMs: 2100, durMs: 0, text: 'Empty' },
+ { startMs: 2200, durMs: 1, text: 'Shorter than a frame' },
+ ] });
+ assert.equal((xml.match(/<title /g) ?? []).length, 2);
+ assert.match(xml, /<gap[^>]*>\s*<title ref="subtitle-title" name="First" lane="1" offset="0\/25s" start="0s" duration="25\/25s"/);
+ assert.match(xml, /name="Second" lane="1" offset="25\/25s" start="0s" duration="25\/25s"/);
+});
+
+test('invalid plans fail instead of silently attaching a connection to an unrelated primary clip', () => {
+ const sound = timeline.audio[0].clips[0];
+ assert.throws(() => fcpxmlDocument({ ...timeline, audio: [{ enabled: true, clips: [
+ { ...sound, start: 90, end: 100 },
+ ] }] }), /no primary storyline segment at frame 90/);
+ const picture = timeline.video[0].clips[0];
+ assert.throws(() => fcpxmlDocument({ ...timeline, video: [{ enabled: true, clips: [
+ { ...picture, start: 0, end: 30 }, { ...picture, start: 20, end: 40 },
+ ] }] }), /primary clips overlap at frame 20/);
+});
+
+const dtd = '/Applications/Final Cut Pro.app/Contents/Frameworks/Interchange.framework/Versions/A/Resources/FCPXMLv1_10.dtd';
+test('FCPXML validates against Final Cut Pro’s installed 1.10 DTD', { skip: !existsSync(dtd) && 'Final Cut Pro DTD not installed' }, () => {
+ const dir = mkdtempSync(join(tmpdir(), 'openfilm-fcpxml-'));
+ try {
+ const file = join(dir, 'Film.fcpxml');
+ const audio = timeline.audio.map((track, i) => ({ ...track, sourceTrack: i }));
+ const cues = [{ startMs: 1100, durMs: 700, text: 'Hello & <world>\nNext line' }];
+ writeFileSync(file, fcpxmlDocument({ ...timeline, audio }, { cues }));
+ const result = spawnSync('/usr/bin/xmllint', ['--noout', '--nonet', '--dtdvalid', pathToFileURL(dtd).href, file], { encoding: 'utf8' });
+ assert.equal(result.status, 0, result.stderr || result.error?.message);
+ } finally { rmSync(dir, { recursive: true, force: true }); }
+});
diff --git a/packages/openfilm/studio/server/film-subtitle.mjs b/packages/openfilm/studio/server/film-subtitle.mjs
index b960fdc..44740a8 100644
--- a/packages/openfilm/studio/server/film-subtitle.mjs
+++ b/packages/openfilm/studio/server/film-subtitle.mjs
@@ -695,7 +695,7 @@ function srtStamp(ms) {
* players disagree on overlaps). Cut, not dropped: the dropped line was really said.
* @param {readonly FilmSubtitleCue[]} cues
*/
-function sequencedCues(cues) {
+export function filmSubtitleSequence(cues) {
const sorted = [...cues].filter((c) => c.text.trim() && c.durMs > 0).sort((a, b) => a.startMs - b.startMs);
/** @type {{ cue: FilmSubtitleCue, end: number }[]} */
const out = [];
@@ -714,7 +714,7 @@ function sequencedCues(cues) {
* @param {readonly FilmSubtitleCue[]} cues
*/
export function filmSubtitleSrt(cues) {
- const blocks = sequencedCues(cues).map(({ cue, end }, i) => {
+ const blocks = filmSubtitleSequence(cues).map(({ cue, end }, i) => {
const line = cue.speaker ? `${cue.speaker}:${cue.text}` : cue.text;
return `${i + 1}\n${srtStamp(cue.startMs)} --> ${srtStamp(end)}\n${line.trim()}`;
});
@@ -726,7 +726,7 @@ const escapeVtt = (/** @type {string} */ s) => s.replace(/&/g, '&amp;').replace(
/** A WebVTT file; the speaker as `<v name>`, VTT's own voice tag. @param {readonly FilmSubtitleCue[]} cues */
export function filmSubtitleVtt(cues) {
- const blocks = sequencedCues(cues).map(({ cue, end }) => {
+ const blocks = filmSubtitleSequence(cues).map(({ cue, end }) => {
const text = escapeVtt(cue.text.trim());
const line = cue.speaker ? `<v ${escapeVtt(cue.speaker)}>${text}` : text;
return `${srtStamp(cue.startMs).replace(',', '.')} --> ${srtStamp(end).replace(',', '.')}\n${line}`;
@@ -740,7 +740,7 @@ export function filmSubtitleTranscript(cues) {
const lines = [];
/** @type {string | undefined} */
let lastSpeaker;
- for (const { cue } of sequencedCues(cues)) {
+ for (const { cue } of filmSubtitleSequence(cues)) {
if (lines.length && cue.speaker !== lastSpeaker) lines.push('');
lines.push(cue.speaker && cue.speaker !== lastSpeaker ? `${cue.speaker}:${cue.text.trim()}` : cue.text.trim());
lastSpeaker = cue.speaker;
diff --git a/packages/openfilm/studio/server/nle.mjs b/packages/openfilm/studio/server/nle.mjs
index 6cb9619..022a30d 100644
--- a/packages/openfilm/studio/server/nle.mjs
+++ b/packages/openfilm/studio/server/nle.mjs
@@ -15,7 +15,7 @@
* Motion can't say (a rotation, a speed change, an unknown size) is rendered too: rather less to adjust than a
* picture in the wrong place.
* · Sound comes as clips (each its own, with its level, footage's sound linked to its picture) on footage, voice,
- * sound-effect and music tracks, or as those four mixed stems.
+ * sound-effect and music tracks, or as those four mixed stems. FCPXML clips instead retain their source rows.
* · A hidden track's clips and a muted track's sounds are not dropped: they come disabled, one click from back on.
* · Fades (film.html `overrides`' `fade`): a picture that fades is rendered, its fades in its alpha; a sound that
* fades comes as a WAV of its own part, from its first frame, with Audio Levels keyframes for its ramps (counted
@@ -37,12 +37,12 @@ import { clipKind, pictureRect, soundRole } from '../../src/film-doc.mjs';
* @typedef {'voice' | 'music' | 'sfx' | 'footage'} SoundRole
* A sound's stem (see soundStem)
* @typedef {{ id: string, src: string, path: string, at: number, from: number, to: number, speed: number, volume: number,
- * enabled: boolean, role: SoundRole, picture?: string, facts: SourceFacts | null, fade?: [number, number] }} NleSound
+ * enabled: boolean, role: SoundRole, track?: number, picture?: string, facts: SourceFacts | null, fade?: [number, number] }} NleSound
* A sound: the source seconds [from, to) at `speed`, placed at film second `at`; `picture`: the footage clip it is
* the sound of; `fade`: its fades in and out, film seconds (fitted to its length)
* @typedef {{ stage: { w: number, h: number }, duration: number, pictures: NlePicture[], sounds: NleSound[] }} NleFilm
* @typedef {{ title: string, fps: number, audio: 'clips' | 'stems', media: 'copy' | 'link', mediaDir: string,
- * stems?: SoundRole[] }} NlePlanOptions
+ * stems?: SoundRole[], audioTracks?: 'roles' | 'source' }} NlePlanOptions
* @typedef {{ timebase: number, ntsc: boolean, fps: number }} NleRate
* @typedef {{ kind: 'render', clip: string, frames: number }
* | { kind: 'copy', from: string }
@@ -53,13 +53,13 @@ import { clipKind, pictureRect, soundRole } from '../../src/film-doc.mjs';
* How a file is made: a clip rendered, a source cloned or pointed at, a still drawn to PNG, a source converted
* (`segment`: only those source seconds, at that speed, `seconds` long), a mixed stem
* @typedef {{ id: string, name: string, path: string, job: NleMediaJob, durationFrames: number,
- * video?: { w: number, h: number, alpha: boolean, still: boolean }, audio?: { channels: number, sampleRate: number } }} NleFile
+ * video?: { w: number, h: number, alpha: boolean, still: boolean, fps?: number }, audio?: { channels: number, sampleRate: number } }} NleFile
* @typedef {{ id: string, name: string, fileId: string, start: number, end: number, in: number, out: number, enabled: boolean,
* motion?: { scale: number, center: { h: number, v: number } }, gain?: number,
* levels?: { when: number, value: number }[], linkGroup?: string }} NleClip
* Sequence frames [start, end), file frames [in, out); `gain` linear; `levels` its gain's keyframes (its fades),
* frames from the clip's first
- * @typedef {{ name: string, enabled: boolean, clips: NleClip[] }} NleTrack
+ * @typedef {{ name: string, enabled: boolean, clips: NleClip[], sourceTrack?: number }} NleTrack
* @typedef {{ name: string, rate: NleRate, width: number, height: number, durationFrames: number, video: NleTrack[],
* audio: NleTrack[], files: NleFile[] }} NleTimeline
*/
@@ -148,8 +148,22 @@ const ROLE_NAME = { footage: 'Footage', voice: 'Voice', sfx: 'SFX', music: 'Musi
const safeStem = (/** @type {string} */ name) => name.replace(/[\\/:*?"<>|\u0000-\u001f]+/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 80) || 'clip';
const stemOf = (/** @type {string} */ src) => (src.split('/').pop() ?? src).replace(/\.[^.]+$/, '');
+/** Stable source-row identity, independent of file names and export formats.
+ * @param {readonly NleSound[]} sounds
+ */
+function sourceAudioGroups(sounds) {
+ const tracks = new Set();
+ for (const sound of sounds) {
+ if (sound.track === undefined) throw new Error(`audio clip ${sound.id} has no source track`);
+ tracks.add(sound.track);
+ }
+ return [...tracks].sort((a, b) => a - b)
+ .map((track, i) => ({ key: `track-${track}`, name: `A${i + 1}`, sourceTrack: track }));
+}
+
/**
* The timeline, planned: tracks, each clip's frames, the file each points at and how that file is made.
+ * Audio clips group by role by default; `audioTracks: 'source'` retains source rows and requires their indices.
* @param {NleFilm} film @param {NlePlanOptions} opts @returns {NleTimeline}
*/
export function planNleTimeline(film, opts) {
@@ -208,7 +222,7 @@ export function planNleTimeline(film, opts) {
file = addFile({
...made,
durationFrames: facts.duration ? Math.max(1, toFrame(facts.duration, rate)) : Math.max(1, minFrames),
- ...(video ? { video: { w: facts.w ?? stage.w, h: facts.h ?? stage.h, alpha: Boolean(facts.alpha), still: false } } : {}),
+ ...(video ? { video: { w: facts.w ?? stage.w, h: facts.h ?? stage.h, alpha: Boolean(facts.alpha), still: false, fps: facts.fps } } : {}),
...(audio ? { audio: converted ? { channels: audio.channels, sampleRate: 48_000 } : audio } : {}),
});
if (facts.duration) measured.add(file.id);
@@ -269,8 +283,13 @@ export function planNleTimeline(film, opts) {
audio.push({ name: ROLE_NAME[role], enabled: true, clips: [{ id: clipId(), name: `${ROLE_NAME[role]} stem`, fileId: file.id, start: 0, end: total, in: 0, out: total, enabled: true }] });
}
} else {
- /** @type {Map<SoundRole, { start: number, end: number, clip: NleClip }[]>} */
- const byRole = new Map();
+ const sourceTracks = opts.audioTracks === 'source';
+ /** @type {{ key: string, name: string, sourceTrack?: number }[]} */
+ const groups = sourceTracks
+ ? sourceAudioGroups(film.sounds)
+ : ROLE_ORDER.map((role) => ({ key: role, name: ROLE_NAME[role] }));
+ /** @type {Map<string, { start: number, end: number, clip: NleClip }[]>} */
+ const byGroup = new Map();
for (const s of film.sounds) {
const length = (s.to - s.from) / s.speed;
if (!(length > 0)) continue;
@@ -313,18 +332,20 @@ export function planNleTimeline(film, opts) {
linked.clip.linkGroup = `link-${linked.clip.id}`;
clip.linkGroup = linked.clip.linkGroup;
}
- const list = byRole.get(s.role) ?? [];
+ const group = sourceTracks ? `track-${s.track}` : s.role;
+ const list = byGroup.get(group) ?? [];
list.push({ start: clip.start, end: clip.end, clip });
- byRole.set(s.role, list);
+ byGroup.set(group, list);
}
- for (const role of ROLE_ORDER) {
- const items = (byRole.get(role) ?? []).sort((a, b) => a.start - b.start);
+ for (const group of groups) {
+ const items = (byGroup.get(group.key) ?? []).sort((a, b) => a.start - b.start);
if (!items.length) continue;
const lanes = allocateLanes(items);
const count = Math.max(0, ...lanes) + 1;
for (let lane = 0; lane < count; lane++) {
const clips = items.filter((_, i) => lanes[i] === lane).map((v) => v.clip);
- audio.push({ name: count > 1 ? `${ROLE_NAME[role]} ${lane + 1}` : ROLE_NAME[role], enabled: clips.some((c) => c.enabled), clips });
+ audio.push({ name: count > 1 ? `${group.name} ${lane + 1}` : group.name, enabled: clips.some((c) => c.enabled), clips,
+ ...(group.sourceTrack !== undefined ? { sourceTrack: group.sourceTrack } : {}) });
}
}
}
diff --git a/packages/openfilm/studio/ui/src/components/export/ExportCenter.tsx b/packages/openfilm/studio/ui/src/components/export/ExportCenter.tsx
index dfd251c..6c5ff75 100644
--- a/packages/openfilm/studio/ui/src/components/export/ExportCenter.tsx
+++ b/packages/openfilm/studio/ui/src/components/export/ExportCenter.tsx
@@ -69,8 +69,12 @@ const DESTS: readonly { id: Dest; icon: React.ReactNode }[] = [
{ id: 'project', icon: <FolderArchive size={16} /> },
];
-/** Editors' names, never translated. */
-const NLE_APP_NAME = { premiere: 'Premiere Pro', resolve: 'DaVinci Resolve' } as const;
+/** XML destinations: names are not translated; formats and help stay with their editor. */
+const NLE_APPS = {
+ premiere: { name: 'Premiere Pro', format: 'xml', hint: 'exportCenter.nleHintPremiere' },
+ resolve: { name: 'DaVinci Resolve', format: 'xml', hint: 'exportCenter.nleHintResolve' },
+ finalcut: { name: 'Final Cut Pro', format: 'fcpxml', hint: 'exportCenter.nleHintFinalCut' },
+} as const;
const DRAFT_APP_NAME = { jianying: '剪映', capcut: 'CapCut' } as const;
/** "As now" in a frame choice: the delivery frame picked beside the player. */
@@ -107,7 +111,7 @@ interface Settings {
/** For an editing program: the sound as clips or as mixed stems. */
/** the app it is for: `draft` 剪映 (in Chinese) or CapCut (elsewhere), the same draft; `auto`: the draft when that app
is on this computer, else Premiere Pro */
- nle: { app: 'auto' | 'draft' | 'premiere' | 'resolve'; fps: number | 'source'; audio: 'clips' | 'stems'; subtitles: boolean };
+ nle: { app: 'auto' | 'draft' | keyof typeof NLE_APPS; fps: number | 'source'; audio: 'clips' | 'stems'; subtitles: boolean };
subtitles: { format: 'srt' | 'vtt' | 'txt' };
images: { format: 'png' | 'jpg'; shortEdge: number; frame: FrameChoice; fill: FilmFrameFill; burn: boolean };
slides: { format: 'pptx' | 'pdf'; shortEdge: number; frame: FrameChoice; fill: FilmFrameFill; burn: boolean };
@@ -144,6 +148,8 @@ function loadSettings(language: string): Settings {
try {
const raw = JSON.parse(localStorage.getItem(STORE_KEY) ?? 'null') as Partial<Settings> | null;
if (!raw || typeof raw !== 'object') return first;
+ const nle = { ...DEFAULTS.nle, ...raw.nle };
+ if (nle.app !== 'auto' && nle.app !== 'draft' && !Object.hasOwn(NLE_APPS, nle.app)) nle.app = 'auto';
return {
...DEFAULTS,
...raw,
@@ -152,7 +158,7 @@ function loadSettings(language: string): Settings {
gif: { ...DEFAULTS.gif, ...raw.gif },
alpha: { ...DEFAULTS.alpha, ...raw.alpha },
audio: { ...DEFAULTS.audio, ...raw.audio },
- nle: { ...DEFAULTS.nle, ...raw.nle },
+ nle,
subtitles: { ...DEFAULTS.subtitles, ...raw.subtitles },
images: { ...DEFAULTS.images, ...raw.images },
slides: { ...DEFAULTS.slides, ...raw.slides },
@@ -407,8 +413,8 @@ export function ExportCenter(props: ExportCenterProps) {
}
case 'nle':
return [{
- kind: 'nle', format: nleApp === 'draft' ? draftApp : 'xml', fps: s.nle.fps === 'source' ? (nleSourceFps ?? projectFps) : s.nle.fps, audio: s.nle.audio, media: 'copy',
- subtitles: s.nle.subtitles, label: nleApp === 'draft' ? tApp('exportCenter.nleDraftTitle') : `${NLE_APP_NAME[nleApp]} XML`,
+ kind: 'nle', format: nleApp === 'draft' ? draftApp : NLE_APPS[nleApp].format, fps: s.nle.fps === 'source' ? (nleSourceFps ?? projectFps) : s.nle.fps, audio: s.nle.audio, media: 'copy',
+ subtitles: s.nle.subtitles, label: nleApp === 'draft' ? tApp('exportCenter.nleDraftTitle') : `${NLE_APPS[nleApp].name} XML`,
}];
case 'subtitles':
return [{ kind: 'subtitles', format: s.subtitles.format, label: s.subtitles.format === 'txt' ? t('exportCenter.transcript') : s.subtitles.format.toUpperCase(), ...ranged }];
@@ -837,8 +843,9 @@ export function ExportCenter(props: ExportCenterProps) {
value={nleApp}
options={[
{ value: 'draft', label: DRAFT_APP_NAME[draftApp] },
- { value: 'premiere', label: NLE_APP_NAME.premiere },
- { value: 'resolve', label: NLE_APP_NAME.resolve },
+ { value: 'premiere', label: NLE_APPS.premiere.name },
+ { value: 'resolve', label: NLE_APPS.resolve.name },
+ { value: 'finalcut', label: NLE_APPS.finalcut.name },
]}
onChange={(app) => patch('nle', { app })}
/>
@@ -863,9 +870,11 @@ export function ExportCenter(props: ExportCenterProps) {
/>
</Field>
{captions > 0 && (
- <Toggle checked={s.nle.subtitles} onChange={(subtitles) => patch('nle', { subtitles })} label={t(nleApp === 'draft' ? 'exportCenter.nleSubs' : 'exportCenter.nleSrt')} />
+ <Toggle checked={s.nle.subtitles} onChange={(subtitles) => patch('nle', { subtitles })} label={t(nleApp === 'draft' || nleApp === 'finalcut' ? 'exportCenter.nleSubs' : 'exportCenter.nleSrt')} />
)}
- <Hint>{tApp(nleApp === 'premiere' ? 'exportCenter.nleHintPremiere' : nleApp === 'resolve' ? 'exportCenter.nleHintResolve' : draftHere ? 'exportCenter.nleHintDraft' : 'exportCenter.nleHintDraftNone')}</Hint>
+ <Hint>{tApp(nleApp === 'draft'
+ ? draftHere ? 'exportCenter.nleHintDraft' : 'exportCenter.nleHintDraftNone'
+ : NLE_APPS[nleApp].hint)}</Hint>
</>
)}
diff --git a/packages/openfilm/studio/ui/src/i18n/en.ts b/packages/openfilm/studio/ui/src/i18n/en.ts
index 8e2e978..ec2c586 100644
--- a/packages/openfilm/studio/ui/src/i18n/en.ts
+++ b/packages/openfilm/studio/ui/src/i18n/en.ts
@@ -302,7 +302,7 @@ export const en = {
slides: 'One slide per shot',
project: 'The whole project, to hand on',
alpha: 'Alpha for AE, Final Cut, web',
- nle: '{app}, Premiere Pro, DaVinci Resolve',
+ nle: '{app}, Final Cut Pro, Premiere Pro, DaVinci Resolve',
},
destDesc: {
social: 'Pick one or more platforms. Each gets the right shape, size and frame rate, and they export in one go.',
@@ -428,6 +428,7 @@ export const en = {
nleDraftTitle: '{app} draft',
nleSrt: 'Include subtitles (SRT)',
nleSubs: 'Include subtitles',
+ nleHintFinalCut: 'Creates a folder with the FCPXML and a media folder. In Final Cut Pro: File › Import › XML. Subtitles come as title clips, with an SRT copy. Final Cut Pro is Mac only: on Windows or Linux, move the folder to a Mac and relink.',
nleHintPremiere: 'Creates a folder with the XML and a media folder. In Premiere Pro: File › Import. Keep the folder where it is, or relink after moving it.',
nleHintResolve: 'Creates a folder with the XML and a media folder. In DaVinci Resolve: File › Import › Timeline. Keep the folder where it is, or relink after moving it.',
nleHintDraft: "Makes a draft in {app}'s drafts folder, so it is on {app}'s home screen (if {app} is open, restart it). Pages come as clips with alpha, subtitles as a text track.",
diff --git a/packages/openfilm/studio/ui/src/i18n/es.ts b/packages/openfilm/studio/ui/src/i18n/es.ts
index 999a236..3f8f71b 100644
--- a/packages/openfilm/studio/ui/src/i18n/es.ts
+++ b/packages/openfilm/studio/ui/src/i18n/es.ts
@@ -301,7 +301,7 @@ export const es: Words = {
slides: 'Una diapositiva por plano',
project: 'El proyecto entero, para pasarlo',
alpha: 'Alfa para AE, Final Cut, web',
- nle: '{app}, Premiere Pro, DaVinci Resolve',
+ nle: '{app}, Final Cut Pro, Premiere Pro, DaVinci Resolve',
},
destDesc: {
social: 'Elige una o más plataformas. Cada una recibe la forma, el tamaño y la velocidad de fotogramas adecuados, y se exportan de una vez.',
@@ -427,6 +427,7 @@ export const es: Words = {
nleDraftTitle: 'Borrador de {app}',
nleSrt: 'Incluir subtítulos (SRT)',
nleSubs: 'Incluir subtítulos',
+ nleHintFinalCut: 'Crea una carpeta con el FCPXML y una carpeta de medios. En Final Cut Pro: Archivo › Importar › XML. Los subtítulos llegan como clips de título, con una copia SRT. Final Cut Pro solo existe para Mac: en Windows o Linux, mueve la carpeta a un Mac y vuelve a enlazar.',
nleHintPremiere: 'Crea una carpeta con el XML y una carpeta de medios. En Premiere Pro: Archivo › Importar. Deja la carpeta donde está o vuelve a vincular los medios tras moverla.',
nleHintResolve: 'Crea una carpeta con el XML y una carpeta de medios. En DaVinci Resolve: Archivo › Importar › Línea de tiempo. Deja la carpeta donde está o vuelve a vincular los medios tras moverla.',
nleHintDraft: 'Crea un borrador en la carpeta de borradores de {app}, así aparece en su pantalla de inicio (si {app} está abierto, reinícialo). Las páginas llegan como clips con alfa y los subtítulos como una pista de texto.',
diff --git a/packages/openfilm/studio/ui/src/i18n/ja.ts b/packages/openfilm/studio/ui/src/i18n/ja.ts
index 4d28f2f..ea27f01 100644
--- a/packages/openfilm/studio/ui/src/i18n/ja.ts
+++ b/packages/openfilm/studio/ui/src/i18n/ja.ts
@@ -301,7 +301,7 @@ export const ja: Words = {
slides: '1 ショット 1 スライド',
project: 'プロジェクト全体を渡す',
alpha: 'AE、Final Cut、Web 用のアルファ付き',
- nle: '{app}、Premiere Pro、DaVinci Resolve',
+ nle: '{app}、Final Cut Pro、Premiere Pro、DaVinci Resolve',
},
destDesc: {
social: 'プラットフォームを 1 つ以上選んでください。それぞれに合った形、サイズ、フレームレートで、まとめて書き出します。',
@@ -427,6 +427,7 @@ export const ja: Words = {
nleDraftTitle: '{app} の下書き',
nleSrt: '字幕を含める(SRT)',
nleSubs: '字幕を含める',
+ nleHintFinalCut: 'FCPXML とメディアフォルダを含むフォルダを作成します。Final Cut Pro で:ファイル › 読み込む › XML。字幕はタイトルクリップになり、SRT も付きます。Final Cut Pro は Mac 専用です。Windows や Linux では、フォルダを Mac に移してから再リンクしてください。',
nleHintPremiere: 'XML とメディアフォルダーを含むフォルダーを作成します。Premiere Pro で:ファイル › 読み込み。フォルダーはそのままの場所に置くか、移動した場合はメディアを再リンクしてください。',
nleHintResolve: 'XML とメディアフォルダーを含むフォルダーを作成します。DaVinci Resolve で:ファイル › 読み込み › タイムライン。フォルダーはそのままの場所に置くか、移動した場合はメディアを再リンクしてください。',
nleHintDraft: '{app} の下書きフォルダーに直接作成するので、{app} のホーム画面に表示されます({app} を開いている場合は再起動してください)。ページはアルファ付きクリップ、字幕はテキストトラックになります。',
diff --git a/packages/openfilm/studio/ui/src/i18n/ko.ts b/packages/openfilm/studio/ui/src/i18n/ko.ts
index e2e8311..dc00f37 100644
--- a/packages/openfilm/studio/ui/src/i18n/ko.ts
+++ b/packages/openfilm/studio/ui/src/i18n/ko.ts
@@ -301,7 +301,7 @@ export const ko: Words = {
slides: '샷마다 슬라이드 1장',
project: '프로젝트 전체를 전달',
alpha: 'AE, Final Cut, 웹용 알파',
- nle: '{app}, Premiere Pro, DaVinci Resolve',
+ nle: '{app}, Final Cut Pro, Premiere Pro, DaVinci Resolve',
},
destDesc: {
social: '플랫폼을 하나 이상 선택하세요. 각 플랫폼에 맞는 화면 비율, 크기, 프레임 레이트로 한 번에 내보냅니다.',
@@ -427,6 +427,7 @@ export const ko: Words = {
nleDraftTitle: '{app} 초안',
nleSrt: '자막 포함(SRT)',
nleSubs: '자막 포함',
+ nleHintFinalCut: 'FCPXML과 미디어 폴더가 담긴 폴더를 만듭니다. Final Cut Pro에서: 파일 › 가져오기 › XML. 자막은 타이틀 클립으로 들어오고 SRT 사본도 함께 저장됩니다. Final Cut Pro는 Mac 전용입니다. Windows나 Linux에서는 폴더를 Mac으로 옮긴 뒤 다시 연결하세요.',
nleHintPremiere: 'XML과 미디어 폴더가 들어 있는 폴더를 만듭니다. Premiere Pro에서: 파일 › 가져오기. 폴더를 그 자리에 두거나, 옮긴 뒤에는 미디어를 다시 연결하세요.',
nleHintResolve: 'XML과 미디어 폴더가 들어 있는 폴더를 만듭니다. DaVinci Resolve에서: 파일 › 가져오기 › 타임라인. 폴더를 그 자리에 두거나, 옮긴 뒤에는 미디어를 다시 연결하세요.',
nleHintDraft: '{app}의 초안 폴더에 바로 만들어서 {app} 홈 화면에 나타납니다({app}이 열려 있으면 다시 시작하세요). 페이지는 알파가 포함된 클립으로, 자막은 텍스트 트랙으로 들어갑니다.',
diff --git a/packages/openfilm/studio/ui/src/i18n/zh-CN.ts b/packages/openfilm/studio/ui/src/i18n/zh-CN.ts
index 1584353..479b46e 100644
--- a/packages/openfilm/studio/ui/src/i18n/zh-CN.ts
+++ b/packages/openfilm/studio/ui/src/i18n/zh-CN.ts
@@ -302,7 +302,7 @@ export const zhCN: Words = {
slides: '每个镜头一页',
project: '整个项目,方便传给别人',
alpha: '带 Alpha 通道,用于 AE、Final Cut、网页',
- nle: '{app}、Premiere Pro、DaVinci Resolve',
+ nle: '{app}、Final Cut Pro、Premiere Pro、DaVinci Resolve',
},
destDesc: {
social: '选择一个或多个平台。每个平台都会得到合适的画幅、尺寸和帧率,一次全部导出。',
@@ -428,6 +428,7 @@ export const zhCN: Words = {
nleDraftTitle: '{app}草稿',
nleSrt: '包含字幕(SRT)',
nleSubs: '包含字幕',
+ nleHintFinalCut: '会生成一个文件夹,内含 FCPXML 和一个媒体文件夹。在 Final Cut Pro 中:文件 › 导入 › XML。字幕是标题片段,另附一份 SRT。Final Cut Pro 只有 Mac 版:在 Windows 或 Linux 上导出的,把文件夹移到 Mac 上再重新链接。',
nleHintPremiere: '会生成一个文件夹,内含 XML 和一个媒体文件夹。在 Premiere Pro 中:文件 › 导入。请保持文件夹位置不变,移动后需要重新链接。',
nleHintResolve: '会生成一个文件夹,内含 XML 和一个媒体文件夹。在 DaVinci Resolve 中:文件 › 导入 › 时间线。请保持文件夹位置不变,移动后需要重新链接。',
nleHintDraft: '直接生成到{app}的草稿文件夹,打开{app}首页就能看到({app}开着的话,重启一下)。页面是带 Alpha 通道的片段,字幕是一条文字轨道。',
diff --git a/packages/openfilm/studio/ui/src/lib/export-jobs.ts b/packages/openfilm/studio/ui/src/lib/export-jobs.ts
index 58afd0c..644b830 100644
--- a/packages/openfilm/studio/ui/src/lib/export-jobs.ts
+++ b/packages/openfilm/studio/ui/src/lib/export-jobs.ts
@@ -18,8 +18,8 @@ export type ExportRequest = { range?: [number, number]; label?: string } & (
| (Framing & { kind: 'poster'; format: 'png' | 'jpg'; shortEdge: number; at?: number })
| { kind: 'subtitles'; format: 'srt' | 'vtt' | 'txt' }
| (Framing & { kind: 'slides'; format: 'pptx' | 'pdf'; shortEdge: number; at?: number[] })
- /* for an editing program: an xmeml folder; `media: 'link'` points at the sources where they are instead of cloning them */
- | { kind: 'nle'; format?: 'xml' | 'jianying' | 'capcut'; fps: number; audio: 'clips' | 'stems'; media?: 'copy' | 'link'; subtitles: boolean }
+ /* for an editing program: an XML and media folder; `media: 'link'` points at the sources where they are instead of cloning them */
+ | { kind: 'nle'; format?: 'xml' | 'fcpxml' | 'jianying' | 'capcut'; fps: number; audio: 'clips' | 'stems'; media?: 'copy' | 'link'; subtitles: boolean }
/* the project itself: its work, and the parts of its .film asked; a zip of its folder, or the folder */
| { kind: 'project'; parts: ProjectPart[]; as: 'zip' | 'folder' }
);