Skip to content

Commit 356886d

Browse files
[Feature] Add MP4 workflow file open support (#3950)
1 parent f96de24 commit 356886d

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Supported workflow file formats organized by type category
3+
*/
4+
5+
/**
6+
* All supported image formats that can contain workflow data
7+
*/
8+
export const IMAGE_WORKFLOW_FORMATS = {
9+
extensions: ['.png', '.webp', '.svg'],
10+
mimeTypes: ['image/png', 'image/webp', 'image/svg+xml']
11+
}
12+
13+
/**
14+
* All supported audio formats that can contain workflow data
15+
*/
16+
export const AUDIO_WORKFLOW_FORMATS = {
17+
extensions: ['.mp3', '.ogg', '.flac'],
18+
mimeTypes: ['audio/mpeg', 'audio/ogg', 'audio/flac', 'audio/x-flac']
19+
}
20+
21+
/**
22+
* All supported video formats that can contain workflow data
23+
*/
24+
export const VIDEO_WORKFLOW_FORMATS = {
25+
extensions: ['.mp4', '.mov', '.m4v', '.webm'],
26+
mimeTypes: ['video/mp4', 'video/quicktime', 'video/x-m4v', 'video/webm']
27+
}
28+
29+
/**
30+
* All supported 3D model formats that can contain workflow data
31+
*/
32+
export const MODEL_WORKFLOW_FORMATS = {
33+
extensions: ['.glb'],
34+
mimeTypes: ['model/gltf-binary']
35+
}
36+
37+
/**
38+
* All supported data formats that directly contain workflow data
39+
*/
40+
export const DATA_WORKFLOW_FORMATS = {
41+
extensions: ['.json', '.latent', '.safetensors'],
42+
mimeTypes: ['application/json']
43+
}
44+
45+
/**
46+
* Combines all supported formats into a single object
47+
*/
48+
export const ALL_WORKFLOW_FORMATS = {
49+
extensions: [
50+
...IMAGE_WORKFLOW_FORMATS.extensions,
51+
...AUDIO_WORKFLOW_FORMATS.extensions,
52+
...VIDEO_WORKFLOW_FORMATS.extensions,
53+
...MODEL_WORKFLOW_FORMATS.extensions,
54+
...DATA_WORKFLOW_FORMATS.extensions
55+
],
56+
mimeTypes: [
57+
...IMAGE_WORKFLOW_FORMATS.mimeTypes,
58+
...AUDIO_WORKFLOW_FORMATS.mimeTypes,
59+
...VIDEO_WORKFLOW_FORMATS.mimeTypes,
60+
...MODEL_WORKFLOW_FORMATS.mimeTypes,
61+
...DATA_WORKFLOW_FORMATS.mimeTypes
62+
]
63+
}
64+
65+
/**
66+
* Generate a comma-separated accept string for file inputs
67+
* Combines all extensions and mime types
68+
*/
69+
export const WORKFLOW_ACCEPT_STRING = [
70+
...ALL_WORKFLOW_FORMATS.extensions,
71+
...ALL_WORKFLOW_FORMATS.mimeTypes
72+
].join(',')

src/scripts/ui.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { WORKFLOW_ACCEPT_STRING } from '@/constants/supportedWorkflowFormats'
12
import { type StatusWsMessageStatus, TaskItem } from '@/schemas/apiSchema'
23
import { useDialogService } from '@/services/dialogService'
34
import { useLitegraphService } from '@/services/litegraphService'
@@ -386,7 +387,7 @@ export class ComfyUI {
386387
const fileInput = $el('input', {
387388
id: 'comfy-file-input',
388389
type: 'file',
389-
accept: '.json,image/png,.latent,.safetensors,image/webp,audio/flac',
390+
accept: WORKFLOW_ACCEPT_STRING,
390391
style: { display: 'none' },
391392
parent: document.body,
392393
onchange: async () => {

0 commit comments

Comments
 (0)