Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): one "Add video or audio" reference button, wider picker
Lincoln Stein7f5ccd22cbdb
diff --git a/docs/src/content/docs/features/gallery.mdx b/docs/src/content/docs/features/gallery.mdxindex 376f35d9d9..e4c0f97465 100644--- a/docs/src/content/docs/features/gallery.mdx+++ b/docs/src/content/docs/features/gallery.mdx@@ -149,8 +149,8 @@ Videos generated by InvokeAI (currently from the Wan 2.2 model family) appear alYou can upload existing videos to a board via the standard drop-or-upload affordance. Everything is stored and served as **H.264/AAC MP4** so it plays in supported browsers, but the upload pipeline now converts on ingest rather than rejecting:- **H.264 in another container** (an iPhone `.mov` recorded with "Most Compatible", `.m4v`, most screen recordings) is losslessly remuxed — near-instant, no quality change.-- **Other codecs** (iPhone "High Efficiency" HEVC, ProRes, VP9, and anything else FFmpeg can decode) are transcoded to H.264. Expect the upload to take roughly the clip's duration on a typical CPU. 10-bit HDR footage is converted to 8-bit without tonemapping, so HDR clips will look flatter than the original — pre-convert those yourself if color fidelity matters.-- **Audio files** (`.mp3`, `.m4a`, `.wav`, `.flac`, `.ogg`, and friends) are wrapped into a video whose frames render the waveform. The clip behaves like any other gallery video — it can be trimmed, played, and used wherever audio-only conditioning accepts a video — without audio being a separate media type.+- **Other codecs** (iPhone "High Efficiency" HEVC, ProRes, VP9, Windows Media `.wmv`, and anything else FFmpeg can decode) are transcoded to H.264. Expect the upload to take roughly the clip's duration on a typical CPU. 10-bit HDR footage is converted to 8-bit without tonemapping, so HDR clips will look flatter than the original — pre-convert those yourself if color fidelity matters.+- **Audio files** (`.mp3`, `.m4a`, `.wav`, `.flac`, `.ogg`, `.wma`, and friends) are wrapped into a video whose frames render the waveform. The clip behaves like any other gallery video — it can be trimmed, played, and used wherever audio-only conditioning accepts a video — without audio being a separate media type.The **Concatenate Videos** and **Extract Video Range** nodes encode video frames only; audio tracks are not preserved. Concatenation requires matching source frame rates unless an explicit output FPS is selected, which retimes the source frames.diff --git a/invokeai/app/api/routers/videos.py b/invokeai/app/api/routers/videos.pyindex 446a4aa300..c34fee7a22 100644--- a/invokeai/app/api/routers/videos.py+++ b/invokeai/app/api/routers/videos.py@@ -66,9 +66,37 @@ VIDEO_MAX_AGE = 31536000# are wrapped into waveform videos so audio clips flow through the video pipeline# (gallery, trim, audio-only reference conditioning) without a first-class audio type.ACCEPTED_VIDEO_MIME_PREFIXES = ("video/",)-ACCEPTED_VIDEO_EXTENSIONS = (".mp4", ".mov", ".m4v", ".webm", ".mkv", ".avi", ".mpg", ".mpeg", ".3gp")+# The extension lists are the fallback for uploads whose type the browser could not+# determine (they arrive as application/octet-stream); the MIME prefixes above accept the+# ordinary case. Everything here is demuxable and decodable by the bundled ffmpeg — ASF+# (Windows Media) included — and lands as H.264/AAC MP4 through the ingest converter.+ACCEPTED_VIDEO_EXTENSIONS = (+ ".mp4",+ ".mov",+ ".m4v",+ ".webm",+ ".mkv",+ ".avi",+ ".mpg",+ ".mpeg",+ ".3gp",+ ".wmv",+ ".asf",+)ACCEPTED_AUDIO_MIME_PREFIXES = ("audio/",)-ACCEPTED_AUDIO_EXTENSIONS = (".mp3", ".m4a", ".aac", ".wav", ".flac", ".ogg", ".oga", ".opus", ".aiff", ".aif")+ACCEPTED_AUDIO_EXTENSIONS = (+ ".mp3",+ ".m4a",+ ".aac",+ ".wav",+ ".flac",+ ".ogg",+ ".oga",+ ".opus",+ ".aiff",+ ".aif",+ ".wma",+)# Per-chunk size for HTTP Range responses (1 MB)RANGE_CHUNK_SIZE = 1024 * 1024diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 17154e7b0b..677bed6fa0 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3445,7 +3445,7 @@},"addImageReference": "Add image ({{count}}/{{max}})","addReference": "Add reference",- "addVideoReference": "Add video ({{count}}/{{max}})",+ "addVideoReference": "Add video or audio ({{count}}/{{max}})","dropReference": "Drop Reference","moveReferenceDown": "Move reference down","moveReferenceUp": "Move reference up",@@ -3458,10 +3458,10 @@"referenceExtendCapFullDescription": "All 3 video reference slots are in use, so there is no room for the continuity reference this clip needs. Remove a video reference, then drop the clip again.","referenceExtendHelp": "The generated video is appended to this clip at its End Frame. A linked video reference samples up to the last ~5 seconds before that cutpoint for continuity — never more than the generated clip's own length, since the model discards the overrun at the seam. Its trim re-derives whenever the cutpoints or the frame count change.","referenceImageCapRace": "All {{max}} image reference slots filled while this one was loading, so it was not added.",- "referenceVideoCapRace": "All {{max}} video reference slots filled while this one was loading, so it was not added.",+ "referenceVideoCapRace": "All {{max}} video or audio reference slots filled while this one was loading, so it was not added.","referenceFromInitialVideo": "Initial video","references": "References",- "referencesHelp": "Up to 3 videos and 9 images condition the generation, in order — reordering references changes the result. A video reference can contribute its image track, its soundtrack, or both.",+ "referencesHelp": "Up to 3 videos and 9 images condition the generation, in order — reordering references changes the result. A video reference can contribute its image track, its soundtrack, or both. An uploaded audio file becomes a waveform clip that fills a video slot and conditions on its soundtrack.","removeReference": "Remove reference","staleReferences": "References are set but the selected model cannot use them."}diff --git a/invokeai/frontend/webv2/src/features/gallery/data/backend.test.ts b/invokeai/frontend/webv2/src/features/gallery/data/backend.test.tsindex 6191e06b07..66f8cea201 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/backend.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/backend.test.ts@@ -782,6 +782,8 @@ describe('classifyGalleryUpload', () => {['application/octet-stream', 'photo.jpeg', 'image'],['application/octet-stream', 'song.mp3', 'video'],['binary/octet-stream', 'clip.MP4', 'video'],+ ['application/octet-stream', 'clip.wmv', 'video'],+ ['application/octet-stream', 'song.WMA', 'video'],['application/pdf', 'photo.png', 'image'],] as const)('classifies MIME %s and name %s as %s', (type, name, kind) => {expect(classifyGalleryUpload(new File(['media'], name, { type }))).toEqual({ kind });diff --git a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts b/invokeai/frontend/webv2/src/features/gallery/data/backend.tsindex 2c3baf4199..02b1942f44 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/backend.ts@@ -102,6 +102,8 @@ const GALLERY_UPLOAD_KIND_BY_EXTENSION = new Map<string, GalleryUploadKind>([['.mpg', 'video'],['.mpeg', 'video'],['.3gp', 'video'],+ ['.wmv', 'video'],+ ['.asf', 'video'],['.mp3', 'video'],['.m4a', 'video'],['.aac', 'video'],@@ -112,6 +114,7 @@ const GALLERY_UPLOAD_KIND_BY_EXTENSION = new Map<string, GalleryUploadKind>([['.opus', 'video'],['.aiff', 'video'],['.aif', 'video'],+ ['.wma', 'video'],]);export const classifyGalleryUpload = (file: Pick<File, 'name' | 'type'>): { kind: GalleryUploadKind } | null => {diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsxindex 63f608f670..e8de7d39ed 100644--- a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx@@ -39,6 +39,37 @@ import { useVideoUiActions } from './VideoUiContext';const DROP_ID = 'video-reference-list';const IMAGE_UPLOAD_ACCEPT = 'image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp';+// One picker for both media kinds: an uploaded audio file becomes a waveform video, so it+// occupies a VIDEO reference slot and shares that cap -- a separate audio button would+// carry the same counter and grey out with it. The wildcards cover the ordinary case; the+// explicit extensions (mirroring the upload route's accepted lists) are what match a file+// whose type the OS could not map, which the browser then offers as octet-stream.+const MEDIA_UPLOAD_ACCEPT = [+ 'video/*',+ 'audio/*',+ '.mp4',+ '.mov',+ '.m4v',+ '.webm',+ '.mkv',+ '.avi',+ '.mpg',+ '.mpeg',+ '.3gp',+ '.wmv',+ '.asf',+ '.mp3',+ '.m4a',+ '.aac',+ '.wav',+ '.flac',+ '.ogg',+ '.oga',+ '.opus',+ '.aiff',+ '.aif',+ '.wma',+].join(',');const DROP_ZONE_FOCUS_PROPS = {outlineColor: 'accent.focusRing',outlineOffset: '2px',@@ -577,7 +608,7 @@ export const VideoReferenceListField = memo(function VideoReferenceListField({<Input accept={IMAGE_UPLOAD_ACCEPT} hidden ref={imageInputRef} type="file" onChange={handleImageFileChange} />{/* Audio files upload too: the server wraps them into waveform videos, which ishow audio-only reference clips enter the pipeline. */}- <Input accept="video/*,audio/*" hidden ref={videoInputRef} type="file" onChange={handleVideoFileChange} />+ <Input accept={MEDIA_UPLOAD_ACCEPT} hidden ref={videoInputRef} type="file" onChange={handleVideoFileChange} /></Stack>);});diff --git a/tests/app/routers/test_videos_multiuser.py b/tests/app/routers/test_videos_multiuser.pyindex f2411e9987..36277daf91 100644--- a/tests/app/routers/test_videos_multiuser.py+++ b/tests/app/routers/test_videos_multiuser.py@@ -12,20 +12,23 @@ filter is covered separately in tests/app/services/video_records."""import inspect+import ioimport jsonfrom pathlib import Pathfrom typing import Anyfrom unittest.mock import MagicMock, patchimport pytest-from fastapi import status+from fastapi import UploadFile, statusfrom fastapi.testclient import TestClientfrom pydantic import ValidationError+from starlette.datastructures import Headersfrom invokeai.app.api.dependencies import ApiDependenciesfrom invokeai.app.api.routers import videos as videos_router_modulefrom invokeai.app.api.routers.videos import (VideoNamesBatch,+ _classify_upload,_is_mp4_file,delete_uncategorized_videos,delete_video,@@ -788,6 +791,29 @@ def test_upload_rejects_unrecognized_file_kind(client: TestClient, mock_invoker:assert response.status_code == status.HTTP_415_UNSUPPORTED_MEDIA_TYPE+ ("filename", "expected"),+ [+ ("clip.wmv", "video"),+ ("clip.asf", "video"),+ ("song.wma", "audio"),+ ("clip.MOV", "video"),+ ("voice.M4A", "audio"),+ ("notes.txt", None),+ ],+)+def test_classify_upload_falls_back_to_the_extension(filename: str, expected: str | None) -> None:+ """A file whose type the browser could not map arrives as octet-stream, leaving the+ extension as the only signal. The picker offers these, so the route must accept them."""+ upload = UploadFile(+ file=io.BytesIO(b""),+ filename=filename,+ headers=Headers({"content-type": "application/octet-stream"}),+ )++ assert _classify_upload(upload) == expected++def test_mp4_validation_allows_boxes_before_file_type(tmp_path: Path) -> None:path = tmp_path / "valid.mp4"path.write_bytes(b"\x00\x00\x00\x08free" + b"\x00\x00\x00\x18ftypmp42" + b"\x00" * 12)