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
Merge origin/main into fix/audio-reference-default-conditioning
Lincoln Steind14646ef1e1d
diff --cc invokeai/frontend/webv2/public/locales/en.jsonindex 677bed6fa0,6681668ad1..4965c0973e--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@@ -3458,12 -3569,13 +3569,13 @@@"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."+ "staleReferences": "References are set but the selected model cannot use them.",- "uploadVideoReference": "Upload video"++ "uploadVideoReference": "Upload video or audio"}},"workflowLibrary": {diff --cc invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsxindex e8de7d39ed,0cb7091a1a..b526b56fb0--- a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx@@@ -6,11 -8,12 +8,12 @@@ import type} from '@features/video/core/types';import type { ChangeEvent } from 'react';- import { Badge, Box, createListCollection, HStack, Image, Input, Spinner, Stack, Text } from '@chakra-ui/react';+ import { Badge, Box, createListCollection, HStack, Icon, Image, Input, Spinner, Stack, Text } from '@chakra-ui/react';import { useDndContext, useDndMonitor, useDroppable } from '@dnd-kit/core';- import { galleryImages, galleryItems, galleryTransfers, galleryVideos } from '@features/gallery';-import { galleryItems, galleryTransfers, toGalleryItemKey } from '@features/gallery';++import { galleryItems, galleryTransfers, galleryVideos, toGalleryItemKey } from '@features/gallery';+ import { GalleryPickerPopover } from '@features/gallery/picker';import { galleryImageUrls, galleryVideoUrls, isGalleryItemDragData } from '@features/gallery/utility';-import { createVideoSourceClip } from '@features/video/core/settings';+import { createVideoSourceClip, getDefaultReferenceConditioning } from '@features/video/core/settings';import {assertAccountScopeCurrent,captureAccountScope,@@@ -39,37 -42,6 +42,37 @@@ import { useVideoUiActions } from './Viconst 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.++// One upload button 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++// grey out with this one. 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',@@@ -387,7 -367,40 +398,47 @@@ export const VideoReferenceListField =setIsLoading(false);}},- [maxImages, onChange, reportError, t]+ [addImageReference, reportError]+ );++ const addVideoItem = useCallback(- (item: GalleryVideoItem) => {++ // The conditioning is passed in rather than derived here: only a caller holding the++ // clip's metadata can tell a wrapped audio upload from footage. Callers without it get++ // the ordinary video default -- and the entry back, so a late answer can correct it.++ (item: GalleryVideoItem, conditioning: VideoReferenceConditioning = 'video_audio') => {+ const clip = createVideoSourceClip(item);++ // Built outside the updater so the caller holds the same object the list does: it is++ // the only durable handle on this entry once reordering moves it.++ const entry: Extract<VideoReferenceItem, { kind: 'video' }> = {++ // References are truncated to the generated duration, not joined: default to++ // the whole clip rather than the extend-mode 2-frame-tail trim.++ clip: { ...clip, endFrame: Math.max(0, clip.numFrames - 1), startFrame: 0 },++ conditioning,++ kind: 'video',++ };+ // Same live cap re-check as the image path -- the Initial Video's+ // anchor is the writer that most easily fills the slots mid-await.+ let declined = false;++ setErrorMessage(null);+ onChange((current) => {- if (current.filter((entry) => entry.kind === 'video').length >= maxVideos) {++ if (current.filter((existing) => existing.kind === 'video').length >= maxVideos) {+ declined = true;++ return current;+ }+- return [- ...current,- {- // References are truncated to the generated duration, not joined: default to- // the whole clip rather than the extend-mode 2-frame-tail trim.- clip: { ...clip, endFrame: Math.max(0, clip.numFrames - 1), startFrame: 0 },- conditioning: 'video_audio',- kind: 'video',- },- ];++ return [...current, entry];+ });+ if (declined) {+ setErrorMessage(t('widgets.video.referenceVideoCapRace', { max: maxVideos }));++++ return null;+ }++++ return entry;+ },+ [maxVideos, onChange, t]);const addVideoReference = useCallback(@@@ -396,49 -409,10 +447,17 @@@setIsLoading(true);try {- const item = await galleryItems.resolve({ kind: 'video', name: videoName });+ // Fetched alongside the resolve, not after it: the metadata only picks the+ // card's starting conditioning, and it must not add a round trip to the add.+ // A missing or unreadable record is not a failure -- it just means the+ // ordinary video default.+ const [item, metadata] = await Promise.all([+ galleryItems.resolve({ kind: 'video', name: videoName }),+ galleryVideos.metadata(videoName).catch(() => null),+ ]);if (item?.kind === 'video') {- const clip = createVideoSourceClip({- durationSeconds: item.durationSeconds,- fps: item.fps,- height: item.height,- name: item.name,- width: item.width,- });-- // Same live cap re-check as the image path -- the Initial Video's- // anchor is the writer that most easily fills the slots mid-await.- let declined = false;-- onChange((current) => {- if (current.filter((entry) => entry.kind === 'video').length >= maxVideos) {- declined = true;-- return current;- }-- return [- ...current,- {- // References are truncated to the generated duration, not joined: default to- // the whole clip rather than the extend-mode 2-frame-tail trim.- clip: { ...clip, endFrame: Math.max(0, clip.numFrames - 1), startFrame: 0 },- conditioning: getDefaultReferenceConditioning(metadata),- kind: 'video',- },- ];- });- if (declined) {- setErrorMessage(t('widgets.video.referenceVideoCapRace', { max: maxVideos }));- }- addVideoItem(item);++ addVideoItem(item, getDefaultReferenceConditioning(metadata));}} catch (error) {const message = error instanceof Error ? error.message : String(error);@@@ -526,6 -500,31 +545,65 @@@[uploadFile]);+ const pickerSelection = useMemo<GalleryPickerSelection>(+ () => ({+ addedKeys: new Set(+ references.map((reference) =>+ reference.kind === 'video'+ ? toGalleryItemKey({ kind: 'video', name: reference.clip.video_name })+ : toGalleryItemKey({ kind: 'image', name: reference.image.image_name })+ )+ ),+ mode: 'multiple',+ remaining: { image: Math.max(0, maxImages - imageCount), video: Math.max(0, maxVideos - videoCount) },+ }),+ [imageCount, maxImages, maxVideos, references, videoCount]+ );++ const addPickedVideo = useCallback(++ (item: GalleryVideoItem) => {++ // The card goes in SYNCHRONOUSLY and is corrected afterwards, rather than waiting on++ // the metadata the way the drop and upload paths do. The picker stays open and judges++ // each click against the reference list as it stands -- an add that had not landed yet++ // would leave the tile pickable (a second click would duplicate it), leave the++ // remaining count stale, and let two picks land in whichever order their fetches++ // finished, which for references is a different generation.++ const entry = addVideoItem(item);++++ if (!entry) {++ return;++ }++++ // The metadata is the only thing that tells a wrapped audio upload from footage. An++ // unreadable record is not a failure -- the ordinary video default just stands.++ void galleryVideos++ .metadata(item.name)++ .then((metadata) => {++ const conditioning = getDefaultReferenceConditioning(metadata);++++ if (conditioning === entry.conditioning) {++ return;++ }++ // Matched by identity, not index: a card the user has since edited is a different++ // object and keeps their choice, and a removed one is simply no longer there.++ onChange((current) =>++ current.map((existing) => (existing === entry ? { ...entry, conditioning } : existing))++ );++ })++ .catch(() => undefined);++ },++ [addVideoItem, onChange]++ );+ const handlePick = useCallback(+ (item: GalleryItem) => {+ if (item.kind === 'video') {- addVideoItem(item);++ addPickedVideo(item);+ } else {+ addImageReference(item);+ }+ },- [addImageReference, addVideoItem]++ [addImageReference, addPickedVideo]+ );+const updateReference = useCallback((index: number, reference: VideoReferenceItem) => {onChange((current) => current.map((entry, entryIndex) => (entryIndex === index ? reference : entry)));