Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: expose fal.ai video backend on Music Video projects (#8968)

[._.]/ Adam Eivy445bb2a0b49d
diff --git a/client/src/components/musicVideo/VideoRenderSettings.jsx b/client/src/components/musicVideo/VideoRenderSettings.jsx
index 4d92e4c24d..acf9e96b95 100644
--- a/client/src/components/musicVideo/VideoRenderSettings.jsx
+++ b/client/src/components/musicVideo/VideoRenderSettings.jsx
@@ -11,6 +11,12 @@ export default function VideoRenderSettings({ videoSettings, generating }) {
audioReactiveModels, audioReactiveLoras, detectedAudioReactiveLora,
audioReactiveReady, audioReactiveSelected, change,
} = videoSettings;
+ // fal.ai (#8968) is image-to-video only here — every scene render already
+ // starts from the director's chosen reference frame, so no generation-mode
+ // picker or model knob is exposed; the server resolves fal.ai's verified
+ // image-to-video model by default (videoGen/fal.js#FAL_DEFAULT_IMAGE_MODEL).
+ // The audio-reactive lane stays local-only (root AGENTS.md's environmental-
+ // motion contract needs an independently verified provider capability).
const locked = saving || generating;
return (
<>
@@ -26,6 +32,7 @@ export default function VideoRenderSettings({ videoSettings, generating }) {
<option value="">Install default</option>
<option value="local">Local video</option>
<option value="grok">Grok video</option>
+ <option value="fal">fal.ai video</option>
</select>
{settings.backend === 'local' && (
<>
@@ -136,6 +143,23 @@ export default function VideoRenderSettings({ videoSettings, generating }) {
</select>
</>
)}
+ {settings.backend === 'fal' && (
+ <>
+ <label htmlFor="mv-fal-duration" className="sr-only">fal.ai scene clip duration</label>
+ <input
+ id="mv-fal-duration"
+ type="number"
+ min={1}
+ max={60}
+ value={settings.falDuration ?? ''}
+ onChange={(e) => change({ falDuration: e.target.value === '' ? null : Number(e.target.value) })}
+ disabled={locked}
+ placeholder="model default"
+ title="Clip length in seconds for this project's fal.ai scene renders (blank uses the model's default)"
+ className="w-full max-w-full bg-port-bg border border-port-border rounded px-1.5 py-1.5 text-sm disabled:opacity-50 sm:w-24"
+ />
+ </>
+ )}
</>
);
}
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 9654415b7d..5761e2d43b 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -248,7 +248,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `useMusicVideoYoutubeImport` | The Music Video page's two independent `useYoutubeTrackImport` slots (create form + detail-view track row) plus their URL drafts, the detail slot's captured target project, and the URL-nav backstop that bounces a deep link / Back / ⌘K jump away from an in-flight import back to its project. Returns `{ createUrl, setCreateUrl, editUrl, setEditUrl, createJob, editJob, startCreate, startEdit, switchBlockedMessage }`. | The Music Video page. Reuse `switchBlockedMessage` for any additional guard (delete, list picker) so every surface says the same thing. |
| `useMusicVideoMidiJob` | `useMidiTranscription` bound to the music-video API surface, plus the MuScriptor model-size picker state (read fresh at each kickoff). Returns the slot (`active`/`stage`/`stageLabel`/`context`/`start(projectId)`/`cancel`/`installGate`/`gatedGate`) plus `{ model, setModel }`; `onTranscribed(projectId, midiTranscription)` fires on a non-discarded terminal frame. | The Music Video MIDI button + model select. |
| `useMusicVideoRenderJob` | The final-render job (#1760 Phase 2): kickoff (409 → attach to the existing job), SSE progress, terminal-frame handling and non-terminal stream-close recovery. Thin `useSseJobSlot` adapter with 0–1 progress conversion; returns `{ active, pending, context, job, progress, start(projectId), cancel }`; `onRendered(projectId, result)` / `onFailed(projectId)` key on the projectId captured at kickoff. | The Music Video "Render final" control. |
-| `useMusicVideoModelSettings` | A project's saved render pins — video backend/model/generation-mode/audio-reactive LoRA + the image-side frame pin — with the Video Gen catalog they read from. Optimistic-local + silent PATCH, rollback + toast on failure; `saving` gates the dependent generate buttons. Returns `{ models, modelsLoading, defaultModel, saving, settings, effectiveModelId, activeModel, audioReactiveModels, audioReactiveLoras, detectedAudioReactiveLora, audioReactiveReady, audioReactiveSelected, videoBlockedReason, change, changeFramePin }`. `videoBlockedReason` is the single "why can't I generate" string (an unavailable audio-reactive setup) shared by the disabled buttons, their tooltips, and the blocked-call toast. | The Music Video renderer selects and anything building a scene-clip job payload from them. |
+| `useMusicVideoModelSettings` | A project's saved render pins — video backend (local/Grok/fal.ai)/model/generation-mode/audio-reactive LoRA + the image-side frame pin — with the Video Gen catalog they read from. Optimistic-local + silent PATCH, rollback + toast on failure; `saving` gates the dependent generate buttons. Returns `{ models, modelsLoading, defaultModel, falEnabled, saving, settings, effectiveModelId, activeModel, audioReactiveModels, audioReactiveLoras, detectedAudioReactiveLora, audioReactiveReady, audioReactiveSelected, videoBlockedReason, change, changeFramePin }`. `videoBlockedReason` is the single "why can't I generate" string (an unavailable audio-reactive setup, or a fal.ai pin with no configured API key) shared by the disabled buttons, their tooltips, and the blocked-call toast. | The Music Video renderer selects and anything building a scene-clip job payload from them. |
| `useMusicVideoSceneMedia` | Both per-scene generation lanes (reference frame + scene clip) over `useSceneRenderLifecycle`, the frame/shot prompt builders (concept-style + visual-spec direction suffix), visual-spec reference-image conditioning with explicit unsupported-backend feedback (#8965), and the batch "generate the missing ones" actions. Returns `{ genScenes, genVideoScenes, conditioning, buildFramePrompt, buildShotPrompt, generateFrame, generateSceneVideo, continueSceneVideo, generateMissingFrames, generateMissingVideos }`. | The Music Video scene board — don't re-wire the two lanes or re-derive the i2v/a2v/extend payloads. |
| `useMusicVideoTakes` | Scene-take review + external-asset handoff for the Music Video board (#8965): serialized select / reject / note / gallery-import take mutations folded back as scene patches, the handoff manifest download, and the handoff import (gallery upload per file, then scene association by file tag with provider provenance). Returns `{ busy, selectTake, reviewTake, importTake, exportHandoff, importHandoffFiles }`. | The Music Video board's take strips, contact sheet and handoff row — don't re-sequence take mutations per call site. |
| `useMusicVideoManualTempo` | The manual-tempo fallback for a project whose auto-detected BPM is null: BPM/offset drafts (reset on project switch), tap-tempo estimation, and the persisted `setMusicVideoManualTempo` call. Returns `{ bpm, setBpm, offset, setOffset, saving, tap, submit }`. | The Music Video "No tempo detected" row. |
diff --git a/client/src/hooks/useMusicVideoModelSettings.js b/client/src/hooks/useMusicVideoModelSettings.js
index 81de470ad9..33cad98cd6 100644
--- a/client/src/hooks/useMusicVideoModelSettings.js
+++ b/client/src/hooks/useMusicVideoModelSettings.js
@@ -26,6 +26,7 @@ export default function useMusicVideoModelSettings({ project, onProjectPatch } =
const [modelsLoading, setModelsLoading] = useState(true);
const [loras, setLoras] = useState([]);
const [defaultModel, setDefaultModel] = useState('');
+ const [falEnabled, setFalEnabled] = useState(false);
const [saving, setSaving] = useState(false);
const [framePinSaving, setFramePinSaving] = useState(false);
@@ -37,6 +38,11 @@ export default function useMusicVideoModelSettings({ project, onProjectPatch } =
// whose runtime supports both text and image conditioning.
setModels((status?.models || []).filter((model) => model.mode !== 't2v' && !model.deprecated));
setDefaultModel(status?.defaultModel || '');
+ // fal.ai's queue REST backend (#8968) — usability-gated on a
+ // configured API key, computed server-side by the same
+ // isVideoModeUsable() check a render itself is gated on (mirrors the
+ // general Video Gen page's `falEnabled`).
+ setFalEnabled(status?.falEnabled === true);
setModelsLoading(false);
})
.catch(() => {
@@ -58,6 +64,9 @@ export default function useMusicVideoModelSettings({ project, onProjectPatch } =
// distinct from pinning the model that happens to be default today.
modelId: project?.videoSettings?.modelId || '',
grokDuration: project?.videoSettings?.grokDuration || 10,
+ // null/absent means "use fal's model default duration" — distinct from an
+ // explicit pin, same null-means-unset contract as modelId above.
+ falDuration: project?.videoSettings?.falDuration ?? null,
generationMode: project?.videoSettings?.generationMode || 'image',
audioReactiveLora: project?.videoSettings?.audioReactiveLora || '',
audioReactiveScale: project?.videoSettings?.audioReactiveScale ?? 1.2,
@@ -79,10 +88,15 @@ export default function useMusicVideoModelSettings({ project, onProjectPatch } =
// One reason string for every scene-video kickoff gate, so the disabled
// buttons, their tooltips, and the toast a blocked call raises all say the
- // same resolvable thing. `null` means nothing is blocking.
+ // same resolvable thing. `null` means nothing is blocking. The fal.ai check
+ // mirrors the general Video Gen page: an unconfigured backend is a clear
+ // preflight reason rather than a request that reaches the server only to
+ // fail with FAL_NOT_CONFIGURED (#8968) — no silent fallback to local/Grok.
const videoBlockedReason = audioReactiveSelected && !audioReactiveReady
? 'Audio-reactive generation requires an installed LTX-2.3 audio-reactive LoRA and an LTX-2.3 local model'
- : null;
+ : settings.backend === 'fal' && !falEnabled
+ ? 'No fal.ai API key configured — set it in Settings → Video Gen (or the FAL_KEY env var) first'
+ : null;
const change = (patch) => {
if (!project || saving) return;
@@ -136,6 +150,7 @@ export default function useMusicVideoModelSettings({ project, onProjectPatch } =
models,
modelsLoading,
defaultModel,
+ falEnabled,
saving,
framePinSaving,
settings,
diff --git a/client/src/hooks/useMusicVideoSceneMedia.js b/client/src/hooks/useMusicVideoSceneMedia.js
index 81c578c4df..b5c76daee3 100644
--- a/client/src/hooks/useMusicVideoSceneMedia.js
+++ b/client/src/hooks/useMusicVideoSceneMedia.js
@@ -194,12 +194,17 @@ export default function useMusicVideoSceneMedia({ project, videoSettings, applyS
...(settings.backend ? { backend: settings.backend } : {}),
...(settings.backend === 'grok'
? { grokDuration: settings.grokDuration }
- : settings.backend === 'local'
- ? { modelId: settings.modelId || undefined, disableAudio: true }
- // A named model is local-only machinery at the server boundary and
- // would force the resolver off a Grok install default. Keep the
- // shared pin saved, but omit it until this peer chooses Local.
- : { grokDuration: settings.grokDuration, disableAudio: true }),
+ // fal.ai (#8968) — image-to-video only (see VideoRenderSettings); an
+ // absent falDuration lets the server fall back to the resolved
+ // model's own default rather than forcing a value.
+ : settings.backend === 'fal'
+ ? { falDuration: settings.falDuration || undefined }
+ : settings.backend === 'local'
+ ? { modelId: settings.modelId || undefined, disableAudio: true }
+ // A named model is local-only machinery at the server boundary and
+ // would force the resolver off a Grok install default. Keep the
+ // shared pin saved, but omit it until this peer chooses Local.
+ : { grokDuration: settings.grokDuration, disableAudio: true }),
mode: audioReactiveSelected ? 'a2v' : 'image',
sourceImageFile: scene.referenceImageId,
...(audioReactiveSelected ? {
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index 09423c90ec..767eb09732 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -473,6 +473,63 @@ describe('MusicVideo project video renderer', () => {
));
});
+ it('persists the fal.ai backend pin (#8968)', async () => {
+ getVideoGenStatus.mockResolvedValueOnce({
+ connected: true,
+ defaultModel: 'ltx23_distilled_q4',
+ falEnabled: true,
+ models: [{ id: 'ltx23_distilled_q4', name: 'LTX-2.3 Distilled Q4', runtime: 'ltx2' }],
+ });
+ await openProject(PROJECT_NO_CLIP);
+
+ fireEvent.change(await screen.findByLabelText('Scene video renderer'), {
+ target: { value: 'fal' },
+ });
+ await waitFor(() => expect(updateMusicVideoProject).toHaveBeenCalledWith(
+ 'mv-2',
+ { videoSettings: { backend: 'fal' } },
+ { silent: true },
+ ));
+ expect(await screen.findByLabelText('fal.ai scene clip duration')).toBeTruthy();
+ });
+
+ it('renders a scene image-to-video through a saved fal.ai pin (#8968)', async () => {
+ getVideoGenStatus.mockResolvedValueOnce({
+ connected: true,
+ defaultModel: 'ltx23_distilled_q4',
+ falEnabled: true,
+ models: [{ id: 'ltx23_distilled_q4', name: 'LTX-2.3 Distilled Q4', runtime: 'ltx2' }],
+ });
+ generateVideo.mockResolvedValue({ jobId: 'fal-video-job' });
+ await openProject({
+ ...PROJECT_NO_CLIP,
+ videoSettings: { backend: 'fal', falDuration: 6 },
+ });
+
+ expect(await screen.findByLabelText('fal.ai scene clip duration')).toHaveProperty('value', '6');
+ fireEvent.click(await findEnabledByRole('button', { name: /^Generate video$/ }));
+ await waitFor(() => expect(generateVideo).toHaveBeenCalledWith(expect.objectContaining({
+ backend: 'fal',
+ falDuration: 6,
+ mode: 'image',
+ sourceImageFile: 'img1',
+ })));
+ expect(generateVideo.mock.calls.at(-1)[0]).not.toHaveProperty('modelId');
+ expect(generateVideo.mock.calls.at(-1)[0]).not.toHaveProperty('disableAudio');
+ });
+
+ it('blocks fal.ai scene generation with a clear preflight reason when no API key is configured', async () => {
+ // getVideoGenStatus's default mock omits falEnabled, so it resolves false —
+ // exactly the "no fal.ai API key configured" install this covers.
+ await openProject({ ...PROJECT_NO_CLIP, videoSettings: { backend: 'fal' } });
+
+ const generate = await screen.findByRole('button', { name: /^Generate video$/ });
+ expect(generate).toBeDisabled();
+ expect(generate).toHaveProperty('title', expect.stringContaining('No fal.ai API key configured'));
+ fireEvent.click(generate);
+ expect(generateVideo).not.toHaveBeenCalled();
+ });
+
it('warns when ready scenes reuse the same frames and clips', async () => {
await openProject({
...PROJECT_WITH_CLIP,
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index c8ed8a8855..0380fee326 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -31,9 +31,17 @@ export const musicVideoConceptSchema = z.object({
// the authoritative installed-model validation when a local render starts.
export const musicVideoVideoSettingsSchema = z.object({
// null clears the per-project pin so this install's configured default wins.
- backend: z.enum(['local', 'grok']).nullable().optional(),
+ // 'fal' is the metered fal.ai queue REST backend (server/services/videoGen/fal.js,
+ // #8968) — image-to-video only here; the audio-reactive lane stays local-only
+ // (see generationMode below).
+ backend: z.enum(['local', 'grok', 'fal']).nullable().optional(),
modelId: z.string().max(64).nullable().optional(),
grokDuration: z.union([z.literal(6), z.literal(10)]).optional(),
+ // fal.ai clip length in seconds. Loosely bounded (not a closed enum) for the
+ // same reason routes/videoGen.js's falDuration is: fal's own model catalog,
+ // not PortOS, owns the set of valid durations per model. null/omitted lets
+ // the backend's model default apply.
+ falDuration: z.number().min(1).max(60).nullable().optional(),
generationMode: z.enum(['image', 'audioReactive']).optional(),
audioReactiveLora: z.string().max(255).regex(/^[^/\\]+\.safetensors$/i).nullable().optional(),
audioReactiveScale: z.number().min(0).max(2).optional(),
diff --git a/server/routes/musicVideo.test.js b/server/routes/musicVideo.test.js
index 9e25114657..95ed181677 100644
--- a/server/routes/musicVideo.test.js
+++ b/server/routes/musicVideo.test.js
@@ -159,6 +159,20 @@ describe('musicVideo routes', () => {
expect(svc.updateProject).toHaveBeenCalledWith('mv-1', { videoSettings });
});
+ it('PATCH /:id accepts the fal.ai video backend with a bounded clip duration (#8968)', async () => {
+ const videoSettings = { backend: 'fal', falDuration: 6 };
+ const r = await request(app).patch('/api/music-video/mv-1').send({ videoSettings });
+ expect(r.status).toBe(200);
+ expect(svc.updateProject).toHaveBeenCalledWith('mv-1', { videoSettings });
+ });
+
+ it('PATCH /:id rejects an out-of-range fal.ai clip duration', async () => {
+ const r = await request(app).patch('/api/music-video/mv-1')
+ .send({ videoSettings: { backend: 'fal', falDuration: 90 } });
+ expect(r.status).toBe(400);
+ expect(svc.updateProject).not.toHaveBeenCalled();
+ });
+
it('PATCH /:id accepts null to clear the project video-backend pin', async () => {
const videoSettings = { backend: null };
const r = await request(app).patch('/api/music-video/mv-1').send({ videoSettings });
diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.js
index 8cdcdd2783..5381bc35d6 100644
--- a/server/services/musicVideo/projectsLogic.js
+++ b/server/services/musicVideo/projectsLogic.js
@@ -112,6 +112,7 @@ export function buildProjectRecord(input, { id, now }) {
backend: videoSettings.backend ?? 'local',
modelId: videoSettings.modelId ?? null,
grokDuration: videoSettings.grokDuration ?? 10,
+ falDuration: videoSettings.falDuration ?? null,
generationMode: videoSettings.generationMode ?? 'image',
audioReactiveLora: videoSettings.audioReactiveLora ?? null,
audioReactiveScale: videoSettings.audioReactiveScale ?? 1.2,
@@ -212,6 +213,7 @@ export function applyProjectPatch(project, patch) {
backend: 'local',
modelId: null,
grokDuration: 10,
+ falDuration: null,
generationMode: 'image',
audioReactiveLora: null,
audioReactiveScale: 1.2,
diff --git a/server/services/musicVideo/projectsLogic.test.js b/server/services/musicVideo/projectsLogic.test.js
index d1f62a1450..a6eb5561ba 100644
--- a/server/services/musicVideo/projectsLogic.test.js
+++ b/server/services/musicVideo/projectsLogic.test.js
@@ -289,6 +289,7 @@ describe('applyProjectPatch', () => {
backend: 'grok',
modelId: null,
grokDuration: 6,
+ falDuration: null,
generationMode: 'image',
audioReactiveLora: null,
audioReactiveScale: 1.2,
@@ -301,6 +302,7 @@ describe('applyProjectPatch', () => {
backend: 'local',
modelId: 'ltx23_distilled_q4',
grokDuration: 6,
+ falDuration: null,
generationMode: 'image',
audioReactiveLora: null,
audioReactiveScale: 1.2,