The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Videos: Fix faces on a finished video opens Fix Faces with it, and an H3 video's start picture as the face
Adarsh068cd2d01771
diff --git a/src/components/fix-faces/fix-faces-tool.tsx b/src/components/fix-faces/fix-faces-tool.tsxindex b1d1b1ce..2a94f724 100644--- a/src/components/fix-faces/fix-faces-tool.tsx+++ b/src/components/fix-faces/fix-faces-tool.tsx@@ -141,11 +141,13 @@ type Meta = { duration?: number; width?: number; height?: number };type Auto = { url: string; blob: Blob } | null;export function FixFacesTool({ app }: { app: { name: string; description: string } }) {- // ?video=<url> (a finished result's "Fix faces"): opens on that clip.- const asked = useSearchParams().get("video");+ // ?video=<url> (a finished result's "Fix faces"): opens on that clip; ?photo=<url> (an H3 video's start picture) is its face.+ const params = useSearchParams();+ const asked = params.get("video");+ const askedPhoto = params.get("photo");const [clip, setClip] = useState<SlotValue | null>(asked ? { ref: asked, preview: asked, kind: "video", name: "video.mp4" } : null);const [meta, setMeta] = useState<Meta>({});- const [photo, setPhoto] = useState<SlotValue | null>(null);+ const [photo, setPhoto] = useState<SlotValue | null>(askedPhoto ? { ref: askedPhoto, preview: askedPhoto, kind: "image", name: "face.jpg" } : null);// The clip's clearest face, and how far the search is: each kept with the clip it belongs to.const [found, setFound] = useState<{ for: string; face: Auto } | null>(null);const [progress, setProgress] = useState<{ for: string; done: number; total: number } | null>(null);diff --git a/src/components/studio/result-actions.tsx b/src/components/studio/result-actions.tsxindex a09240d0..cd578ff8 100644--- a/src/components/studio/result-actions.tsx+++ b/src/components/studio/result-actions.tsx@@ -2,6 +2,7 @@import {ArchiveRestore,+ ScanFace,LetterText,Disc3,Layers3,@@ -146,6 +147,7 @@ export const ACTION_ICONS: Record<OutputActionId, LucideIcon> = {"delete-own": Trash2,restore: ArchiveRestore,"restore-video": Palette,+ "fix-faces": ScanFace,"export-pro": Film,"extend-song": ListMusic,"remix-song": Disc3,diff --git a/src/lib/catalog/fix-faces.ts b/src/lib/catalog/fix-faces.tsindex 1dd76a1c..717d808d 100644--- a/src/lib/catalog/fix-faces.ts+++ b/src/lib/catalog/fix-faces.ts@@ -30,6 +30,15 @@ export const FIX_FACES_DEMO = {export type FixFacesClip = { url: string; name?: string; duration?: number; width?: number; height?: number };+/**+ * Fix Faces with a finished video in, and the picture it was made from as the face when it had one (an H3 video from a+ * start picture: the face the video was meant to have).+ */+export function fixFacesHref(video: string, photo?: string): string {+ const q = encodeURIComponent;+ return `/apps/${FIX_FACES.appId}?video=${q(video)}${photo ? `&photo=${q(photo)}` : ""}`;+}+/** The part of the clip one run fixes: from the start, at most maxSeconds. */export function fixFacesRange(duration: number | undefined): { start: number; end: number } | undefined {if (!duration || !Number.isFinite(duration) || duration <= 0) return undefined;diff --git a/src/lib/output-actions.ts b/src/lib/output-actions.tsindex 81befc7e..42f0bde2 100644--- a/src/lib/output-actions.ts+++ b/src/lib/output-actions.ts@@ -18,6 +18,7 @@ import { canEnhance, canRerender, ENHANCE_LABEL, REGEN_OFFERED, regenerateFamilyimport { CLEAN_FEATURE } from "./av/clean-voice";import { exportsCleanly } from "./av/keying";import { anyAngleHref } from "./catalog/any-angle";+import { FIX_FACES, fixFacesHref } from "./catalog/fix-faces";import { isInstrumental, lyricsOf, songFormat, STEMS_FORMATS } from "./lyrics";import { CLEAN_DIALOGUE_FEATURE, cleanDialogueHref } from "./av/clean-dialogue";import { MAX_SIDE as MAX_WATERMARK_SIDE, WATERMARK_APP_ID, WATERMARK_FEATURE } from "./watermark";@@ -80,6 +81,7 @@ export type OutputActionId =| "delete-own"| "restore"| "restore-video"+ | "fix-faces"| "export-pro"| "delete-forever";@@ -195,6 +197,12 @@ export function outputActions(g: Generation, index: number, ctx: ActionContext =// Old, faded or black-and-white footage (Fuobe Restore): Video tools → Restore & colourise with the clip in. It runs// on the viewer's own GPU or fal.ai key (own-setup.ts), and says so.out.push({ id: "restore-video", label: "Restore & colourise", href: `/video-tools/restore?video=${q(o.url)}`, placement: "menu", ownSetup: "video-tools:restore" });+ // Soft or smeared faces (MiniMax H3's small faces): Fix Faces with the clip in, and the start picture as the face+ // when the video was made from one. Not offered on Fix Faces' own results.+ if (g.status === "succeeded" && g.feature !== FIX_FACES.feature) {+ const start = /minimax-h3/.test(g.modelId) ? g.request.inputs?.images?.[0] : undefined;+ out.push({ id: "fix-faces", label: "Fix faces", href: fixFacesHref(o.url, start), placement: "menu", ownSetup: FIX_FACES.model });+ }// A mask or clean foreground from Remove background or Green screen: on to ProRes 4444 or EXR for the edit (Export runs on// your GPU). A cut-out isn't offered: Export would drop its transparency (src/lib/av/keying.ts).if (ctx.engineMode !== "cloud" && exportsCleanly(g.op, g.request?.params)) link("export-pro", "Export as ProRes or EXR", `/upscale/export?video=${q(o.url)}&format=prores_4444`);diff --git a/tests/fix-faces.test.ts b/tests/fix-faces.test.tsindex 2163f3d0..8cb01602 100644--- a/tests/fix-faces.test.ts+++ b/tests/fix-faces.test.ts@@ -76,3 +76,17 @@ describe("Fix Faces app", () => {expect(PRESET_PREVIEWS["app-fix-faces"]?.video).toMatch(/app-fix-faces\.mp4\?v=/);});});++describe("the Fix faces action on a finished video", () => {+ it("opens Fix Faces with the clip, and an H3 video's start picture as the face", async () => {+ const { outputActions } = await import("@/lib/output-actions");+ const g = (over: Record<string, unknown>) =>+ ({ id: "g1", status: "succeeded", modelId: "oss-minimax-h3", engine: "open", feature: "studio", op: "i2v", prompt: "", outputs: [{ kind: "video", url: "/api/files/v.mp4" }], request: { inputs: { images: ["/api/files/start.png"] } }, ...over }) as never;+ const h3 = outputActions(g({}), 0).find((a) => a.id === "fix-faces");+ expect(h3?.href).toBe("/apps/app-fix-faces?video=%2Fapi%2Ffiles%2Fv.mp4&photo=%2Fapi%2Ffiles%2Fstart.png");+ expect(h3?.ownSetup).toBe("oss-h3-fix-faces");+ const other = outputActions(g({ modelId: "wan-2-2", request: { inputs: { images: ["/api/files/start.png"] } } }), 0).find((a) => a.id === "fix-faces");+ expect(other?.href).toBe("/apps/app-fix-faces?video=%2Fapi%2Ffiles%2Fv.mp4");+ expect(outputActions(g({ feature: "app:app-fix-faces" }), 0).some((a) => a.id === "fix-faces")).toBe(false);+ });+});diff --git a/tests/library-pure.test.ts b/tests/library-pure.test.tsindex 1420ad03..432a37ae 100644--- a/tests/library-pure.test.ts+++ b/tests/library-pure.test.ts@@ -117,6 +117,7 @@ describe("outputActions", () => {"menu:lipsync","menu:upscale","menu:restore-video",+ "menu:fix-faces","menu:add-sound","menu:split-soundtrack","menu:remove-dialogue",