uncleh00ru

VideoConfigAnimate

Nov 25th, 2025
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.30 KB | Source Code | 0 0
  1. # custom_nodes/video_config_animate.py
  2. import re
  3.  
  4. try:
  5.     from server import PromptServer
  6. except Exception:
  7.     PromptServer = None
  8.  
  9.  
  10. class VideoConfig:
  11.     @classmethod
  12.     def INPUT_TYPES(cls):
  13.         return {
  14.             "required": {
  15.                 "preset": ([
  16.                     "640x352",
  17.                     "960x544",
  18.                     "1280x720",
  19.                     "1536x864",
  20.                     "1920x1080",
  21.                 ], {"default": "1280x720"}),
  22.                 "custom_width":  ("INT", {"default": 0, "min": 0, "max": 8192, "step": 8}),
  23.                 "custom_height": ("INT", {"default": 0, "min": 0, "max": 8192, "step": 8}),
  24.                 "invert":        ("BOOLEAN", {"default": False}),
  25.                 "custom_frames": ("INT", {"default": 0, "min": 0, "max": 100000, "step": 1}),
  26.                 "fps":           ("INT", {"default": 30, "min": 1, "max": 240, "step": 1}),
  27.                 "frame_load_cap":    ("INT", {"default": 0, "min": 0, "max": 100000, "step": 1}),
  28.                 "skip_first_frames": ("INT", {"default": 0, "min": 0, "max": 100000, "step": 1}),
  29.             },
  30.             "hidden": {
  31.                 "unique_id": "UNIQUE_ID",
  32.             },
  33.         }
  34.  
  35.     RETURN_TYPES = ("INT", "INT", "INT", "FLOAT", "INT", "INT")
  36.     RETURN_NAMES = ("width", "height", "frame_count", "fps", "frame_load_cap", "skip_first_frames")
  37.     FUNCTION = "select"
  38.     CATEGORY = "utils"
  39.  
  40.     def select(self, preset, custom_width, custom_height, custom_frames, fps, invert, frame_load_cap, skip_first_frames, unique_id=None):
  41.         # Parse preset resolution
  42.         m = re.match(r"^(\d+)x(\d+)$", preset)
  43.         if not m:
  44.             raise ValueError(f"Invalid preset format: {preset}")
  45.         w, h = int(m.group(1)), int(m.group(2))
  46.         f = 150  # Default frame count
  47.  
  48.         # Override with custom values
  49.         if custom_width  > 0: w = custom_width
  50.         if custom_height > 0: h = custom_height
  51.         if custom_frames > 0: f = custom_frames
  52.  
  53.         # Invert width/height
  54.         if invert:
  55.             w, h = h, w
  56.  
  57.         return (w, h, f, float(fps), frame_load_cap, skip_first_frames)
  58.  
  59.  
  60. NODE_CLASS_MAPPINGS = {
  61.     "VideoConfigAnimate": VideoConfig
  62. }
  63.  
  64. NODE_DISPLAY_NAME_MAPPINGS = {
  65.     "VideoConfigAnimate": "Video Config (Animate)"
  66. }
  67.  
Add Comment
Please, Sign In to add comment