-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFlowState_VideoCreator.py
More file actions
105 lines (82 loc) · 2.72 KB
/
FlowState_VideoCreator.py
File metadata and controls
105 lines (82 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Project: FlowState Video Creator
# Description: Simple Create Video / Save Video combo.
# Version: 0.0.1
# Author: Johnathan Chivington
# Contact: flowstateeng@gmail.com | youtube.com/@flowstateeng
##
# SYSTEM STATUS
##
print(f'\t - 🟢 🎥 Loaded FlowState Video Creator.')
##
# FS IMPORTS
##
from .FS_Types import *
from .FlowState_Node import FlowState_Node
##
# OUTSIDE IMPORTS
##
import time, types
from comfy_api.latest import ComfyExtension, io, ui
from comfy_extras.nodes_video import CreateVideo
from comfy_extras.nodes_video import SaveVideo
##
# NODES
##
class FlowState_VideoCreator(FlowState_Node):
CATEGORY = 'FlowState Creator Suite/Video'
DESCRIPTION = 'Simple Create Video / Save Video combo.'
FUNCTION = 'execute'
OUTPUT_NODE = True
RETURN_TYPES = ()
RETURN_NAMES = ()
OUTPUT_TOOLTIPS = ()
def __init__(self):
super().__init__('🌊🎥 FlowState Video Creator')
self.video_params = None
@classmethod
def INPUT_TYPES(s):
return {
'required': {
'frames': TYPE_FRAMES_IN,
'fps': TYPE_FPS,
'format': TYPE_VIDEO_FORMAT,
'codec': TYPE_VIDEO_CODEC,
'filename_prefix': TYPE_FILENAME_PREFIX,
},
'optional': {
'audio': TYPE_AUDIO_IN,
},
'hidden': {
'prompt': 'PROMPT',
'extra_pnginfo': 'EXTRA_PNGINFO'
}
}
def create_video(self):
self.video = CreateVideo.execute(
self.video_params['frames'],
self.video_params['fps'],
self.video_params['audio']
)[0]
def save_video(self):
hidden_inputs = types.SimpleNamespace()
hidden_inputs.prompt = self.video_params['prompt']
hidden_inputs.extra_pnginfo = self.video_params['extra_pnginfo']
SaveVideo.hidden = hidden_inputs
self.node_output = SaveVideo.execute(
self.video,
self.video_params['filename_prefix'],
self.video_params['format'],
self.video_params['codec']
)
def execute(self, frames, fps, format, codec, filename_prefix, audio=None, prompt=None, extra_pnginfo=None):
self.print_status([('Preparing video...',)], init=True)
self.video_params = locals()
self.create_video()
self.save_video()
create_start_time = time.time()
create_duration, create_mins, create_secs = get_mins_and_secs(create_start_time)
self.print_status([
('Video creation complete.',),
('Creation Time', f'{create_mins}m {create_secs}s ({create_duration}s)'),
], end=True)
return self.node_output