@remotion/studio 4.0.522 → 4.0.523
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/install-package.js +4 -2
- package/dist/components/AssetAudioVolume.d.ts +5 -0
- package/dist/components/AssetAudioVolume.js +33 -0
- package/dist/components/Canvas.js +5 -6
- package/dist/components/CaptionInspector.js +74 -20
- package/dist/components/CheckboardToggle.js +8 -6
- package/dist/components/Checkbox.d.ts +1 -0
- package/dist/components/Checkbox.js +2 -2
- package/dist/components/CompositionContextButton.js +4 -1
- package/dist/components/CompositionSelectorItem.js +2 -2
- package/dist/components/ConfigureLicenseModal.js +1 -1
- package/dist/components/CurrentAsset.js +40 -6
- package/dist/components/EditorContexts.js +3 -1
- package/dist/components/ElementInstallConfirmation.js +287 -135
- package/dist/components/FixComputedValueModal.js +38 -8
- package/dist/components/FullscreenToggle.js +9 -8
- package/dist/components/GlobalKeybindings.js +50 -49
- package/dist/components/HighlightedElementSource.d.ts +5 -0
- package/dist/components/HighlightedElementSource.js +78 -0
- package/dist/components/InspectorPanel/MultiSequenceField.d.ts +12 -0
- package/dist/components/InspectorPanel/MultiSequenceField.js +131 -0
- package/dist/components/InspectorPanel/MultiSequenceInspector.d.ts +8 -0
- package/dist/components/InspectorPanel/MultiSequenceInspector.js +102 -0
- package/dist/components/InspectorPanel/MultiSequenceNumberField.d.ts +9 -0
- package/dist/components/InspectorPanel/MultiSequenceNumberField.js +88 -0
- package/dist/components/InspectorPanel.js +4 -0
- package/dist/components/InspectorSequenceSection.js +64 -1
- package/dist/components/InstallPackage.js +4 -5
- package/dist/components/KeyboardShortcutsSettings.js +212 -33
- package/dist/components/MenuToolbar.js +7 -5
- package/dist/components/ModalContainer.d.ts +1 -0
- package/dist/components/ModalContainer.js +2 -2
- package/dist/components/Modals.js +3 -1
- package/dist/components/ModelManager.d.ts +16 -0
- package/dist/components/ModelManager.js +200 -0
- package/dist/components/ModelsSettings.d.ts +2 -0
- package/dist/components/ModelsSettings.js +133 -0
- package/dist/components/NewComposition/DismissableModal.d.ts +1 -0
- package/dist/components/NewComposition/DismissableModal.js +2 -2
- package/dist/components/NewComposition/InputDragger.d.ts +2 -2
- package/dist/components/NewComposition/InputDragger.js +6 -6
- package/dist/components/NewComposition/NewFolder.js +11 -8
- package/dist/components/NewComposition/RenameFolder.js +17 -10
- package/dist/components/OptionalPackageModal.d.ts +11 -0
- package/dist/components/OptionalPackageModal.js +155 -0
- package/dist/components/PlayPause.js +4 -8
- package/dist/components/PlaybackKeyboardShortcutsManager.js +3 -6
- package/dist/components/PreviewToolbarOverflowButton.js +11 -2
- package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.js +5 -2
- package/dist/components/RadioButton.d.ts +1 -0
- package/dist/components/RadioButton.js +2 -2
- package/dist/components/RenderButton.js +5 -1
- package/dist/components/RenderModal/NumberSetting.d.ts +6 -1
- package/dist/components/RenderModal/NumberSetting.js +2 -2
- package/dist/components/RenderModal/RenderModalBasic.js +1 -1
- package/dist/components/RenderModal/RenderModalOutputName.d.ts +3 -1
- package/dist/components/RenderModal/RenderModalOutputName.js +4 -4
- package/dist/components/RenderModal/SeparateAudioOption.js +1 -1
- package/dist/components/RenderModal/WebRenderModalBasic.js +1 -1
- package/dist/components/RenderQueue/CaptionQueueItem.d.ts +6 -0
- package/dist/components/RenderQueue/CaptionQueueItem.js +129 -0
- package/dist/components/RenderQueue/CaptionQueueProcessor.d.ts +1 -0
- package/dist/components/RenderQueue/CaptionQueueProcessor.js +110 -0
- package/dist/components/RenderQueue/CaptionQueueProcessorLoader.d.ts +2 -0
- package/dist/components/RenderQueue/CaptionQueueProcessorLoader.js +54 -0
- package/dist/components/RenderQueue/RenderQueueItem.js +3 -3
- package/dist/components/RenderQueue/VideoMattingQueueItem.d.ts +6 -0
- package/dist/components/RenderQueue/VideoMattingQueueItem.js +129 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessor.d.ts +1 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessor.js +105 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessorLoader.d.ts +2 -0
- package/dist/components/RenderQueue/VideoMattingQueueProcessorLoader.js +54 -0
- package/dist/components/RenderQueue/caption-job-types.d.ts +47 -0
- package/dist/components/RenderQueue/caption-job-types.js +7 -0
- package/dist/components/RenderQueue/context.d.ts +16 -0
- package/dist/components/RenderQueue/context.js +224 -11
- package/dist/components/RenderQueue/index.js +34 -10
- package/dist/components/RenderQueue/item-style.d.ts +1 -0
- package/dist/components/RenderQueue/item-style.js +2 -1
- package/dist/components/RenderQueue/load-model-for-job.d.ts +11 -0
- package/dist/components/RenderQueue/load-model-for-job.js +14 -0
- package/dist/components/RenderQueue/video-matting-job-types.d.ts +38 -0
- package/dist/components/RenderQueue/video-matting-job-types.js +5 -0
- package/dist/components/RendersTab.js +4 -4
- package/dist/components/SegmentedControl.d.ts +2 -2
- package/dist/components/SegmentedControl.js +38 -13
- package/dist/components/SelectedOutlinePolygon.js +8 -2
- package/dist/components/SettingsButton.d.ts +4 -0
- package/dist/components/SettingsButton.js +49 -0
- package/dist/components/SettingsModal.d.ts +1 -1
- package/dist/components/SettingsModal.js +3 -1
- package/dist/components/ShowOutlinesProvider.js +12 -0
- package/dist/components/SidebarCollapserControls.js +10 -11
- package/dist/components/SizeSelector.js +10 -2
- package/dist/components/SkillsSettings.js +2 -3
- package/dist/components/SnappingToggle.js +5 -2
- package/dist/components/Tabs/vertical.d.ts +1 -0
- package/dist/components/Tabs/vertical.js +2 -2
- package/dist/components/TimeValue.js +2 -3
- package/dist/components/Timeline/SequencePropsObserver.js +4 -0
- package/dist/components/Timeline/Timeline.js +2 -42
- package/dist/components/Timeline/TimelineClipboardKeybindings.js +2 -4
- package/dist/components/Timeline/TimelineDeleteKeybindings.js +3 -18
- package/dist/components/Timeline/TimelineDragHandler.js +2 -2
- package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +1 -0
- package/dist/components/Timeline/TimelineRowChrome.js +11 -3
- package/dist/components/Timeline/TimelineSchemaField.js +8 -4
- package/dist/components/Timeline/TimelineSelection.d.ts +2 -0
- package/dist/components/Timeline/TimelineSelection.js +55 -2
- package/dist/components/Timeline/TimelineSequence.js +75 -17
- package/dist/components/Timeline/TimelineSequenceItem.d.ts +0 -1
- package/dist/components/Timeline/TimelineSequenceItem.js +208 -111
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +23 -3
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +73 -25
- package/dist/components/Timeline/TimelineTimeIndicators.js +1 -0
- package/dist/components/Timeline/use-asset-timeline-context-menu.d.ts +2 -0
- package/dist/components/Timeline/use-asset-timeline-context-menu.js +52 -0
- package/dist/components/TimelineInOutToggle.js +20 -17
- package/dist/components/Transcription/LazyModels.d.ts +1 -0
- package/dist/components/Transcription/LazyModels.js +5 -0
- package/dist/components/Transcription/Models.d.ts +6 -0
- package/dist/components/Transcription/Models.js +18 -0
- package/dist/components/Transcription/TranscriptionModal.d.ts +3 -0
- package/dist/components/Transcription/TranscriptionModal.js +428 -0
- package/dist/components/Transcription/TranscriptionModalWithOptionalWhisper.d.ts +5 -0
- package/dist/components/Transcription/TranscriptionModalWithOptionalWhisper.js +48 -0
- package/dist/components/Transcription/caption-output-name.d.ts +2 -0
- package/dist/components/Transcription/caption-output-name.js +10 -0
- package/dist/components/Transcription/resample-media-to-16-khz.d.ts +6 -0
- package/dist/components/Transcription/resample-media-to-16-khz.js +82 -0
- package/dist/components/Transcription/whisper-languages.d.ts +2 -0
- package/dist/components/Transcription/whisper-languages.js +104 -0
- package/dist/components/Transcription/whisper-webgpu-capability.d.ts +2 -0
- package/dist/components/Transcription/whisper-webgpu-capability.js +7 -0
- package/dist/components/UndoRedoButtons.js +13 -38
- package/dist/components/UpdatesSettings.js +8 -12
- package/dist/components/VideoMatting/LazyModels.d.ts +1 -0
- package/dist/components/VideoMatting/LazyModels.js +5 -0
- package/dist/components/VideoMatting/Models.d.ts +6 -0
- package/dist/components/VideoMatting/Models.js +18 -0
- package/dist/components/VideoMatting/VideoMattingModal.d.ts +3 -0
- package/dist/components/VideoMatting/VideoMattingModal.js +207 -0
- package/dist/components/VideoMatting/VideoMattingModalWithOptionalPackage.d.ts +5 -0
- package/dist/components/VideoMatting/VideoMattingModalWithOptionalPackage.js +46 -0
- package/dist/components/VideoMatting/video-matting-capability.d.ts +2 -0
- package/dist/components/VideoMatting/video-matting-capability.js +7 -0
- package/dist/components/WebMcp.js +439 -22
- package/dist/components/import-assets.d.ts +3 -2
- package/dist/components/import-assets.js +5 -9
- package/dist/components/keyboard-shortcuts.d.ts +17 -1
- package/dist/components/keyboard-shortcuts.js +177 -89
- package/dist/components/public-output-name.d.ts +5 -0
- package/dist/components/public-output-name.js +60 -0
- package/dist/components/use-model-cache-status.d.ts +7 -0
- package/dist/components/use-model-cache-status.js +35 -0
- package/dist/esm/CaptionQueueProcessor-k0yrm3dj.mjs +211 -0
- package/dist/esm/HighlightedElementSource-jfc66k4p.mjs +1236 -0
- package/dist/esm/LazyModels-2trdm224.mjs +11 -0
- package/dist/esm/LazyModels-fjb5ckaq.mjs +11 -0
- package/dist/esm/TranscriptionModal-916jqhry.mjs +1011 -0
- package/dist/esm/VideoMattingModal-2tm79s9b.mjs +374 -0
- package/dist/esm/VideoMattingQueueProcessor-t1hgm2rm.mjs +109 -0
- package/dist/esm/index-1x7bsdh6.mjs +261 -0
- package/dist/esm/index-3hgr6gjx.mjs +41 -0
- package/dist/esm/index-5qddp5h7.mjs +36 -0
- package/dist/esm/index-5zrb1ft4.mjs +39 -0
- package/dist/esm/index-6cvm9a65.mjs +45923 -0
- package/dist/esm/index-7tt71e8n.mjs +36 -0
- package/dist/esm/index-9x6e1dq0.mjs +428 -0
- package/dist/esm/index-cw0pnpg5.mjs +50 -0
- package/dist/esm/index-czwvnn9g.mjs +35 -0
- package/dist/esm/index-hy4xcgty.mjs +1366 -0
- package/dist/esm/{chunk-je0h1bgt.js → index-jg13hf2g.mjs} +3 -1
- package/dist/esm/{chunk-6jf1natv.js → index-rcv7qkt5.mjs} +18 -1
- package/dist/esm/index-sgtmgc4h.mjs +423 -0
- package/dist/esm/index-te66vvrp.mjs +142 -0
- package/dist/esm/index-v4tr1bft.mjs +20 -0
- package/dist/esm/index-x7t2y7ws.mjs +54194 -0
- package/dist/esm/index-xhe2m2qr.mjs +1146 -0
- package/dist/esm/index.mjs +45 -933
- package/dist/esm/internals.mjs +13 -114393
- package/dist/esm/previewEntry.mjs +387 -115050
- package/dist/esm/renderEntry.mjs +3 -3
- package/dist/esm/{chunk-m0jqdbkr.js → resolve-composition-component-location-14148845.mjs} +1 -1
- package/dist/helpers/drag-aware-double-click.d.ts +2 -1
- package/dist/helpers/drag-aware-double-click.js +12 -1
- package/dist/helpers/get-asset-metadata.d.ts +1 -0
- package/dist/helpers/get-asset-metadata.js +4 -0
- package/dist/helpers/hoverable.js +8 -0
- package/dist/helpers/inject-css.js +2 -0
- package/dist/helpers/optional-package-dependencies.d.ts +3 -0
- package/dist/helpers/optional-package-dependencies.js +24 -0
- package/dist/helpers/pointer-session.d.ts +6 -0
- package/dist/helpers/pointer-session.js +36 -14
- package/dist/helpers/prism-tomorrow.d.ts +1 -0
- package/dist/helpers/prism-tomorrow.js +151 -0
- package/dist/helpers/sequence-node-path-mutations.js +11 -0
- package/dist/helpers/slugify-name.d.ts +1 -0
- package/dist/helpers/slugify-name.js +14 -0
- package/dist/helpers/studio-runtime-config.d.ts +1 -0
- package/dist/helpers/studio-runtime-config.js +6 -1
- package/dist/helpers/use-keybinding.d.ts +9 -3
- package/dist/helpers/use-keybinding.js +8 -9
- package/dist/helpers/use-keyboard-shortcut-label.d.ts +2 -0
- package/dist/helpers/use-keyboard-shortcut-label.js +15 -0
- package/dist/helpers/use-menu-structure.js +58 -13
- package/dist/icons/input-props.d.ts +1 -1
- package/dist/icons/input-props.js +2 -2
- package/dist/icons/models.d.ts +4 -0
- package/dist/icons/models.js +7 -0
- package/dist/icons/separation.d.ts +4 -0
- package/dist/icons/separation.js +7 -0
- package/dist/icons/transcription.d.ts +4 -0
- package/dist/icons/transcription.js +7 -0
- package/dist/icons/upload.js +1 -1
- package/dist/state/modals.d.ts +14 -2
- package/package.json +34 -20
- package/dist/components/UpdateCheck.d.ts +0 -1
- package/dist/components/UpdateCheck.js +0 -79
- package/dist/esm/chunk-3netyjd9.js +0 -99793
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useModelCacheStatus
|
|
3
|
+
} from "./index-7tt71e8n.mjs";
|
|
4
|
+
import {
|
|
5
|
+
RenderModalOutputName
|
|
6
|
+
} from "./index-te66vvrp.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Button,
|
|
9
|
+
Checkmark,
|
|
10
|
+
Combobox,
|
|
11
|
+
DismissableModal,
|
|
12
|
+
ModalHeader,
|
|
13
|
+
ModelsIcon,
|
|
14
|
+
RenderModalHr,
|
|
15
|
+
SeparationIcon,
|
|
16
|
+
SetSelectedModalContext,
|
|
17
|
+
SidebarContext,
|
|
18
|
+
VerticalTab,
|
|
19
|
+
getDefaultOutputBaseName,
|
|
20
|
+
input,
|
|
21
|
+
label,
|
|
22
|
+
optionRow,
|
|
23
|
+
optionsSidebarTabs,
|
|
24
|
+
persistSelectedOptionsSidebarPanel,
|
|
25
|
+
rightRow,
|
|
26
|
+
useStaticFiles,
|
|
27
|
+
validatePublicOutputName
|
|
28
|
+
} from "./index-6cvm9a65.mjs";
|
|
29
|
+
import {
|
|
30
|
+
RenderQueueContext
|
|
31
|
+
} from "./index-9x6e1dq0.mjs";
|
|
32
|
+
import"./index-hy4xcgty.mjs";
|
|
33
|
+
import"./index-cw0pnpg5.mjs";
|
|
34
|
+
import {
|
|
35
|
+
Models
|
|
36
|
+
} from "./index-czwvnn9g.mjs";
|
|
37
|
+
import"./index-1x7bsdh6.mjs";
|
|
38
|
+
import {
|
|
39
|
+
VERTICAL_SCROLLBAR_CLASSNAME,
|
|
40
|
+
ValidationMessage,
|
|
41
|
+
buttonStyle,
|
|
42
|
+
container,
|
|
43
|
+
flexer,
|
|
44
|
+
horizontalLayout,
|
|
45
|
+
horizontalTab,
|
|
46
|
+
icon,
|
|
47
|
+
iconContainer,
|
|
48
|
+
leftSidebar,
|
|
49
|
+
optionsPanel,
|
|
50
|
+
outerModalStyle
|
|
51
|
+
} from "./index-xhe2m2qr.mjs";
|
|
52
|
+
import"./index-5zrb1ft4.mjs";
|
|
53
|
+
import {
|
|
54
|
+
BLUE_DISABLED
|
|
55
|
+
} from "./index-jg13hf2g.mjs";
|
|
56
|
+
import"./index-rcv7qkt5.mjs";
|
|
57
|
+
|
|
58
|
+
// src/components/VideoMatting/VideoMattingModal.tsx
|
|
59
|
+
import { formatBytes } from "@remotion/studio-shared";
|
|
60
|
+
import {
|
|
61
|
+
canUseVideoMatting,
|
|
62
|
+
getAvailableModels,
|
|
63
|
+
isVideoMattingModelCached
|
|
64
|
+
} from "@remotion/video-matting";
|
|
65
|
+
import {
|
|
66
|
+
useCallback,
|
|
67
|
+
useContext,
|
|
68
|
+
useEffect,
|
|
69
|
+
useMemo,
|
|
70
|
+
useState
|
|
71
|
+
} from "react";
|
|
72
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
73
|
+
var MODELS = getAvailableModels();
|
|
74
|
+
var controlStyle = { width: 330, maxWidth: "100%" };
|
|
75
|
+
var panelStyle = {
|
|
76
|
+
...optionsPanel,
|
|
77
|
+
flexDirection: "column",
|
|
78
|
+
paddingTop: 16
|
|
79
|
+
};
|
|
80
|
+
var modalStyle = {
|
|
81
|
+
...outerModalStyle,
|
|
82
|
+
height: "auto",
|
|
83
|
+
maxHeight: "calc(100vh - 40px)",
|
|
84
|
+
minHeight: outerModalStyle.height,
|
|
85
|
+
outline: "none"
|
|
86
|
+
};
|
|
87
|
+
var modalLayout = {
|
|
88
|
+
...horizontalLayout,
|
|
89
|
+
flex: "1 1 auto"
|
|
90
|
+
};
|
|
91
|
+
var hiddenPanel = { display: "none" };
|
|
92
|
+
var validationStyle = { padding: "0 16px 8px" };
|
|
93
|
+
var makeOptions = ({
|
|
94
|
+
items,
|
|
95
|
+
selected,
|
|
96
|
+
setSelected
|
|
97
|
+
}) => items.map(({ id, label: optionLabel }) => ({
|
|
98
|
+
type: "item",
|
|
99
|
+
id,
|
|
100
|
+
value: id,
|
|
101
|
+
label: optionLabel,
|
|
102
|
+
leftItem: id === selected ? /* @__PURE__ */ jsx(Checkmark, {}) : null,
|
|
103
|
+
keyHint: null,
|
|
104
|
+
quickSwitcherLabel: null,
|
|
105
|
+
subMenu: null,
|
|
106
|
+
disabled: false,
|
|
107
|
+
onClick: () => setSelected(id)
|
|
108
|
+
}));
|
|
109
|
+
var VideoMattingModal = ({
|
|
110
|
+
displayName,
|
|
111
|
+
src
|
|
112
|
+
}) => {
|
|
113
|
+
const [tab, setTab] = useState("separate");
|
|
114
|
+
const isModelCached = useCallback((selectedModel) => isVideoMattingModelCached({ model: selectedModel }), []);
|
|
115
|
+
const cachedModels = useModelCacheStatus({
|
|
116
|
+
isModelCached,
|
|
117
|
+
models: MODELS,
|
|
118
|
+
refreshKey: tab
|
|
119
|
+
});
|
|
120
|
+
const baseName = useMemo(() => getDefaultOutputBaseName(src, displayName, "video"), [displayName, src]);
|
|
121
|
+
const [baseOutName, setBaseOutName] = useState(`${baseName}-base.webm`);
|
|
122
|
+
const [foregroundOutName, setForegroundOutName] = useState(`${baseName}-foreground.webm`);
|
|
123
|
+
const [model, setModel] = useState("ben2-base");
|
|
124
|
+
const [audio, setAudio] = useState("base");
|
|
125
|
+
const [videoBitrate, setVideoBitrate] = useState("very-high");
|
|
126
|
+
const [support, setSupport] = useState({ type: "checking" });
|
|
127
|
+
const staticFiles = useStaticFiles();
|
|
128
|
+
const { addVideoMattingJob, videoMattingJobs } = useContext(RenderQueueContext);
|
|
129
|
+
const { setSelectedModal } = useContext(SetSelectedModalContext);
|
|
130
|
+
const { setSidebarCollapsedState } = useContext(SidebarContext);
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
let cancelled = false;
|
|
133
|
+
setSupport({ type: "checking" });
|
|
134
|
+
canUseVideoMatting({ model }).then((result) => {
|
|
135
|
+
if (!cancelled) {
|
|
136
|
+
setSupport(result.supported ? { type: "supported" } : { type: "unsupported", message: result.detailedReason });
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return () => {
|
|
140
|
+
cancelled = true;
|
|
141
|
+
};
|
|
142
|
+
}, [model]);
|
|
143
|
+
const normalizedBase = baseOutName.normalize("NFC").toLowerCase();
|
|
144
|
+
const normalizedForeground = foregroundOutName.normalize("NFC").toLowerCase();
|
|
145
|
+
const duplicateOutput = normalizedBase === normalizedForeground;
|
|
146
|
+
const queuedOutputs = new Set(videoMattingJobs.filter((job) => job.status === "idle" || job.status === "running").flatMap((job) => [job.baseOutName, job.foregroundOutName]).map((name) => name.normalize("NFC").toLowerCase()));
|
|
147
|
+
const baseError = validatePublicOutputName({ extension: ".webm", outName: baseOutName }) ?? (duplicateOutput ? "Base and foreground outputs must be different" : queuedOutputs.has(normalizedBase) ? "Another video matting job is using this output file" : null);
|
|
148
|
+
const foregroundError = validatePublicOutputName({
|
|
149
|
+
extension: ".webm",
|
|
150
|
+
outName: foregroundOutName
|
|
151
|
+
}) ?? (duplicateOutput ? "Base and foreground outputs must be different" : queuedOutputs.has(normalizedForeground) ? "Another video matting job is using this output file" : null);
|
|
152
|
+
const baseExists = staticFiles.some((file) => file.name.normalize("NFC").toLowerCase() === normalizedBase);
|
|
153
|
+
const foregroundExists = staticFiles.some((file) => file.name.normalize("NFC").toLowerCase() === normalizedForeground);
|
|
154
|
+
const canSubmit = support.type === "supported" && baseError === null && foregroundError === null;
|
|
155
|
+
const modelOptions = useMemo(() => makeOptions({
|
|
156
|
+
items: MODELS.map((item) => ({
|
|
157
|
+
id: item.name,
|
|
158
|
+
label: `${item.name} · ${formatBytes(item.webGpuDownloadSize)}${cachedModels.has(item.name) ? " · Downloaded" : ""}`
|
|
159
|
+
})),
|
|
160
|
+
selected: model,
|
|
161
|
+
setSelected: setModel
|
|
162
|
+
}), [cachedModels, model]);
|
|
163
|
+
const audioOptions = useMemo(() => makeOptions({
|
|
164
|
+
items: [
|
|
165
|
+
{ id: "base", label: "Background layer" },
|
|
166
|
+
{ id: "foreground", label: "Foreground layer" },
|
|
167
|
+
{ id: "both", label: "Both layers" },
|
|
168
|
+
{ id: "none", label: "No audio" }
|
|
169
|
+
],
|
|
170
|
+
selected: audio,
|
|
171
|
+
setSelected: setAudio
|
|
172
|
+
}), [audio]);
|
|
173
|
+
const qualityOptions = useMemo(() => makeOptions({
|
|
174
|
+
items: ["very-low", "low", "medium", "high", "very-high"].map((id) => ({
|
|
175
|
+
id,
|
|
176
|
+
label: id.split("-").map((part) => part[0].toUpperCase() + part.slice(1)).join(" ")
|
|
177
|
+
})),
|
|
178
|
+
selected: videoBitrate,
|
|
179
|
+
setSelected: setVideoBitrate
|
|
180
|
+
}), [videoBitrate]);
|
|
181
|
+
const submit = useCallback(() => {
|
|
182
|
+
if (!canSubmit)
|
|
183
|
+
return;
|
|
184
|
+
addVideoMattingJob({
|
|
185
|
+
src,
|
|
186
|
+
displayName,
|
|
187
|
+
baseOutName,
|
|
188
|
+
foregroundOutName,
|
|
189
|
+
model,
|
|
190
|
+
audio,
|
|
191
|
+
videoBitrate
|
|
192
|
+
});
|
|
193
|
+
setSidebarCollapsedState({ left: null, right: "expanded" });
|
|
194
|
+
persistSelectedOptionsSidebarPanel("renders");
|
|
195
|
+
optionsSidebarTabs.current?.selectRendersPanel();
|
|
196
|
+
setSelectedModal(null);
|
|
197
|
+
}, [
|
|
198
|
+
addVideoMattingJob,
|
|
199
|
+
audio,
|
|
200
|
+
baseOutName,
|
|
201
|
+
canSubmit,
|
|
202
|
+
displayName,
|
|
203
|
+
foregroundOutName,
|
|
204
|
+
model,
|
|
205
|
+
setSelectedModal,
|
|
206
|
+
setSidebarCollapsedState,
|
|
207
|
+
src,
|
|
208
|
+
videoBitrate
|
|
209
|
+
]);
|
|
210
|
+
return /* @__PURE__ */ jsx(DismissableModal, {
|
|
211
|
+
ariaLabel: `Track matting ${displayName}`,
|
|
212
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
213
|
+
style: modalStyle,
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ jsx(ModalHeader, {
|
|
216
|
+
title: `Track matting ${displayName}`
|
|
217
|
+
}),
|
|
218
|
+
/* @__PURE__ */ jsxs("div", {
|
|
219
|
+
style: container,
|
|
220
|
+
children: [
|
|
221
|
+
/* @__PURE__ */ jsx("div", {
|
|
222
|
+
style: flexer
|
|
223
|
+
}),
|
|
224
|
+
/* @__PURE__ */ jsx(Button, {
|
|
225
|
+
disabled: !canSubmit,
|
|
226
|
+
onClick: submit,
|
|
227
|
+
title: support.type === "unsupported" ? support.message : undefined,
|
|
228
|
+
style: {
|
|
229
|
+
...buttonStyle,
|
|
230
|
+
backgroundColor: canSubmit ? buttonStyle.backgroundColor : BLUE_DISABLED
|
|
231
|
+
},
|
|
232
|
+
children: "Separate"
|
|
233
|
+
})
|
|
234
|
+
]
|
|
235
|
+
}),
|
|
236
|
+
/* @__PURE__ */ jsxs("div", {
|
|
237
|
+
style: modalLayout,
|
|
238
|
+
children: [
|
|
239
|
+
/* @__PURE__ */ jsxs("div", {
|
|
240
|
+
style: leftSidebar,
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ jsx(VerticalTab, {
|
|
243
|
+
autoFocus: true,
|
|
244
|
+
onClick: () => setTab("separate"),
|
|
245
|
+
renderIcon: (color) => /* @__PURE__ */ jsx("div", {
|
|
246
|
+
style: iconContainer,
|
|
247
|
+
children: /* @__PURE__ */ jsx(SeparationIcon, {
|
|
248
|
+
color,
|
|
249
|
+
style: icon
|
|
250
|
+
})
|
|
251
|
+
}),
|
|
252
|
+
selected: tab === "separate",
|
|
253
|
+
style: horizontalTab,
|
|
254
|
+
children: "Separate"
|
|
255
|
+
}),
|
|
256
|
+
/* @__PURE__ */ jsx(VerticalTab, {
|
|
257
|
+
onClick: () => setTab("models"),
|
|
258
|
+
renderIcon: (color) => /* @__PURE__ */ jsx("div", {
|
|
259
|
+
style: iconContainer,
|
|
260
|
+
children: /* @__PURE__ */ jsx(ModelsIcon, {
|
|
261
|
+
color,
|
|
262
|
+
style: icon
|
|
263
|
+
})
|
|
264
|
+
}),
|
|
265
|
+
selected: tab === "models",
|
|
266
|
+
style: horizontalTab,
|
|
267
|
+
children: "Models"
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
}),
|
|
271
|
+
/* @__PURE__ */ jsxs("div", {
|
|
272
|
+
style: tab === "separate" ? panelStyle : hiddenPanel,
|
|
273
|
+
className: VERTICAL_SCROLLBAR_CLASSNAME,
|
|
274
|
+
children: [
|
|
275
|
+
/* @__PURE__ */ jsx(RenderModalOutputName, {
|
|
276
|
+
ariaLabel: "Base video output file",
|
|
277
|
+
existingOutputPath: window.remotion_publicFolderExists ? `${window.remotion_publicFolderExists}/${baseOutName}` : null,
|
|
278
|
+
existence: baseExists,
|
|
279
|
+
inputStyle: input,
|
|
280
|
+
label: "Base output in public/",
|
|
281
|
+
onValueChange: (event) => setBaseOutName(event.target.value),
|
|
282
|
+
outName: baseOutName,
|
|
283
|
+
validationMessage: baseError
|
|
284
|
+
}),
|
|
285
|
+
/* @__PURE__ */ jsx(RenderModalOutputName, {
|
|
286
|
+
ariaLabel: "Foreground video output file",
|
|
287
|
+
existingOutputPath: window.remotion_publicFolderExists ? `${window.remotion_publicFolderExists}/${foregroundOutName}` : null,
|
|
288
|
+
existence: foregroundExists,
|
|
289
|
+
inputStyle: input,
|
|
290
|
+
label: "Foreground output in public/",
|
|
291
|
+
onValueChange: (event) => setForegroundOutName(event.target.value),
|
|
292
|
+
outName: foregroundOutName,
|
|
293
|
+
validationMessage: foregroundError
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ jsx(RenderModalHr, {}),
|
|
296
|
+
/* @__PURE__ */ jsxs("div", {
|
|
297
|
+
style: optionRow,
|
|
298
|
+
children: [
|
|
299
|
+
/* @__PURE__ */ jsx("div", {
|
|
300
|
+
style: label,
|
|
301
|
+
children: "Model"
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ jsx("div", {
|
|
304
|
+
style: rightRow,
|
|
305
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
306
|
+
values: modelOptions,
|
|
307
|
+
selectedId: model,
|
|
308
|
+
title: "Model",
|
|
309
|
+
style: controlStyle
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
]
|
|
313
|
+
}),
|
|
314
|
+
support.type === "unsupported" ? /* @__PURE__ */ jsx("div", {
|
|
315
|
+
style: validationStyle,
|
|
316
|
+
children: /* @__PURE__ */ jsx(ValidationMessage, {
|
|
317
|
+
align: "flex-end",
|
|
318
|
+
message: support.message,
|
|
319
|
+
type: "error"
|
|
320
|
+
})
|
|
321
|
+
}) : null,
|
|
322
|
+
/* @__PURE__ */ jsxs("div", {
|
|
323
|
+
style: optionRow,
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx("div", {
|
|
326
|
+
style: label,
|
|
327
|
+
children: "Audio"
|
|
328
|
+
}),
|
|
329
|
+
/* @__PURE__ */ jsx("div", {
|
|
330
|
+
style: rightRow,
|
|
331
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
332
|
+
values: audioOptions,
|
|
333
|
+
selectedId: audio,
|
|
334
|
+
title: "Audio",
|
|
335
|
+
style: controlStyle
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
}),
|
|
340
|
+
/* @__PURE__ */ jsxs("div", {
|
|
341
|
+
style: optionRow,
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ jsx("div", {
|
|
344
|
+
style: label,
|
|
345
|
+
children: "Video quality"
|
|
346
|
+
}),
|
|
347
|
+
/* @__PURE__ */ jsx("div", {
|
|
348
|
+
style: rightRow,
|
|
349
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
350
|
+
values: qualityOptions,
|
|
351
|
+
selectedId: String(videoBitrate),
|
|
352
|
+
title: "Video quality",
|
|
353
|
+
style: controlStyle
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
]
|
|
357
|
+
})
|
|
358
|
+
]
|
|
359
|
+
}),
|
|
360
|
+
/* @__PURE__ */ jsx(Models, {
|
|
361
|
+
description: `Models are downloaded automatically when needed.
|
|
362
|
+
You can also manage the browser cache here.`,
|
|
363
|
+
indent: true,
|
|
364
|
+
visible: tab === "models"
|
|
365
|
+
})
|
|
366
|
+
]
|
|
367
|
+
})
|
|
368
|
+
]
|
|
369
|
+
})
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
export {
|
|
373
|
+
VideoMattingModal
|
|
374
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadModelForJob
|
|
3
|
+
} from "./index-v4tr1bft.mjs";
|
|
4
|
+
import {
|
|
5
|
+
RenderQueueContext
|
|
6
|
+
} from "./index-9x6e1dq0.mjs";
|
|
7
|
+
import {
|
|
8
|
+
writeStaticFile
|
|
9
|
+
} from "./index-cw0pnpg5.mjs";
|
|
10
|
+
import"./index-rcv7qkt5.mjs";
|
|
11
|
+
|
|
12
|
+
// src/components/RenderQueue/VideoMattingQueueProcessor.tsx
|
|
13
|
+
import {
|
|
14
|
+
canUseVideoMatting,
|
|
15
|
+
disposeVideoMattingModel,
|
|
16
|
+
isVideoMattingModelCached,
|
|
17
|
+
loadVideoMattingModel,
|
|
18
|
+
separateVideoLayers
|
|
19
|
+
} from "@remotion/video-matting";
|
|
20
|
+
import { useCallback, useContext, useEffect } from "react";
|
|
21
|
+
var VideoMattingQueueProcessor = () => {
|
|
22
|
+
const {
|
|
23
|
+
markVideoMattingJobDone,
|
|
24
|
+
markVideoMattingJobFailed,
|
|
25
|
+
setProcessVideoMattingJobCallback,
|
|
26
|
+
updateVideoMattingJobProgress
|
|
27
|
+
} = useContext(RenderQueueContext);
|
|
28
|
+
const processJob = useCallback(async (job) => {
|
|
29
|
+
let outputs = null;
|
|
30
|
+
let processingError = null;
|
|
31
|
+
try {
|
|
32
|
+
updateVideoMattingJobProgress(job.id, {
|
|
33
|
+
detail: null,
|
|
34
|
+
message: "Checking WebGPU support...",
|
|
35
|
+
value: 0
|
|
36
|
+
});
|
|
37
|
+
const support = await canUseVideoMatting({ model: job.model });
|
|
38
|
+
if (!support.supported) {
|
|
39
|
+
throw new Error(support.detailedReason);
|
|
40
|
+
}
|
|
41
|
+
await loadModelForJob({
|
|
42
|
+
model: job.model,
|
|
43
|
+
progressStart: 0,
|
|
44
|
+
progressSpan: 0.2,
|
|
45
|
+
isModelCached: (model) => isVideoMattingModelCached({ model }),
|
|
46
|
+
loadModel: (model, onProgress) => loadVideoMattingModel({
|
|
47
|
+
model,
|
|
48
|
+
onProgress: (progress) => onProgress(progress.progress)
|
|
49
|
+
}),
|
|
50
|
+
updateProgress: (progress) => updateVideoMattingJobProgress(job.id, {
|
|
51
|
+
...progress,
|
|
52
|
+
detail: null
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
outputs = await separateVideoLayers({
|
|
56
|
+
src: job.src,
|
|
57
|
+
model: job.model,
|
|
58
|
+
audio: job.audio,
|
|
59
|
+
videoBitrate: job.videoBitrate,
|
|
60
|
+
onProgress: (progress) => {
|
|
61
|
+
updateVideoMattingJobProgress(job.id, {
|
|
62
|
+
detail: progress.stage === "finalizing" ? `Processed ${progress.processedFrames} ${progress.processedFrames === 1 ? "frame" : "frames"}` : `Processed ${progress.processedFrames} ${progress.processedFrames === 1 ? "frame" : "frames"} · ${Math.round(progress.progress * 100)}%`,
|
|
63
|
+
message: progress.stage === "finalizing" ? "Finalizing video layers..." : "Separating foreground...",
|
|
64
|
+
value: 0.2 + (progress.progress ?? 1) * 0.65
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
updateVideoMattingJobProgress(job.id, {
|
|
69
|
+
detail: null,
|
|
70
|
+
message: "Saving video layers...",
|
|
71
|
+
value: 0.88
|
|
72
|
+
});
|
|
73
|
+
const [base, foreground] = await Promise.all([
|
|
74
|
+
outputs.base.getBlob(),
|
|
75
|
+
outputs.foreground.getBlob()
|
|
76
|
+
]);
|
|
77
|
+
await Promise.all([
|
|
78
|
+
base.arrayBuffer().then((contents) => writeStaticFile({ contents, filePath: job.baseOutName })),
|
|
79
|
+
foreground.arrayBuffer().then((contents) => writeStaticFile({ contents, filePath: job.foregroundOutName }))
|
|
80
|
+
]);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
processingError = error instanceof Error ? error : new Error(String(error));
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
await Promise.all([
|
|
86
|
+
outputs?.base.dispose(),
|
|
87
|
+
outputs?.foreground.dispose()
|
|
88
|
+
]);
|
|
89
|
+
await disposeVideoMattingModel({ model: job.model });
|
|
90
|
+
} catch {}
|
|
91
|
+
if (processingError) {
|
|
92
|
+
markVideoMattingJobFailed(job.id, processingError);
|
|
93
|
+
} else {
|
|
94
|
+
markVideoMattingJobDone(job.id);
|
|
95
|
+
}
|
|
96
|
+
}, [
|
|
97
|
+
markVideoMattingJobDone,
|
|
98
|
+
markVideoMattingJobFailed,
|
|
99
|
+
updateVideoMattingJobProgress
|
|
100
|
+
]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
setProcessVideoMattingJobCallback(processJob);
|
|
103
|
+
return () => setProcessVideoMattingJobCallback(null);
|
|
104
|
+
}, [processJob, setProcessVideoMattingJobCallback]);
|
|
105
|
+
return null;
|
|
106
|
+
};
|
|
107
|
+
export {
|
|
108
|
+
VideoMattingQueueProcessor
|
|
109
|
+
};
|