Add node video previews (#2635)

This commit is contained in:
bymyself
2025-02-22 16:37:42 -07:00
committed by GitHub
parent c502b86c31
commit f94831d054
12 changed files with 374 additions and 149 deletions

View File

@@ -7,7 +7,11 @@ import { applyTextReplacements } from '../../scripts/utils'
app.registerExtension({
name: 'Comfy.SaveImageExtraOutput',
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === 'SaveImage' || nodeData.name === 'SaveAnimatedWEBP') {
if (
nodeData.name === 'SaveImage' ||
nodeData.name === 'SaveAnimatedWEBP' ||
nodeData.name === 'SaveAnimatedWEBM'
) {
const onNodeCreated = nodeType.prototype.onNodeCreated
// When the SaveImage node is created we want to override the serialization of the output name widget to run our S&R
nodeType.prototype.onNodeCreated = function () {

View File

@@ -4,10 +4,17 @@ import { app } from '../../scripts/app'
// Adds an upload button to the nodes
const isImageComboInput = (inputSpec: InputSpec) => {
const isMediaUploadComboInput = (inputSpec: InputSpec) => {
const [inputName, inputOptions] = inputSpec
if (!inputOptions || inputOptions['image_upload'] !== true) return false
return isComboInputSpecV1(inputSpec) || inputName === 'COMBO'
if (!inputOptions) return false
const isUploadInput =
inputOptions['image_upload'] === true ||
inputOptions['video_upload'] === true
return (
isUploadInput && (isComboInputSpecV1(inputSpec) || inputName === 'COMBO')
)
}
const createUploadInput = (
@@ -29,10 +36,10 @@ app.registerExtension({
if (!required) return
const found = Object.entries(required).find(([_, input]) =>
isImageComboInput(input)
isMediaUploadComboInput(input)
)
// If image combo input found, attach upload input
// If media combo input found, attach upload input
if (found) {
const [inputName, inputSpec] = found
required.upload = createUploadInput(inputName, inputSpec)