Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01a9d17b42 | ||
|
|
f4f5a5c7c5 | ||
|
|
bcac6e1a33 | ||
|
|
96e5fa3ae8 | ||
|
|
4418ba9454 | ||
|
|
fefe43ebe3 |
+5
-2
@@ -14,6 +14,7 @@ from .seq_processing import *
|
||||
from .switches import *
|
||||
from .utility import *
|
||||
from .calculate import *
|
||||
from .laboratory import *
|
||||
|
||||
_NODE_CLASSES: List[Type] = [DreamSineWave, DreamLinear, DreamCSVCurve, DreamBeatCurve, DreamFrameDimensions,
|
||||
DreamImageMotion, DreamNoiseFromPalette, DreamAnalyzePalette, DreamColorShift,
|
||||
@@ -26,12 +27,14 @@ _NODE_CLASSES: List[Type] = [DreamSineWave, DreamLinear, DreamCSVCurve, DreamBea
|
||||
DreamFrameCountCalculator, DreamBigImageSwitch, DreamBigTextSwitch, DreamBigFloatSwitch,
|
||||
DreamBigIntSwitch, DreamBigPaletteSwitch, DreamWeightedPromptBuilder, DreamPromptFinalizer,
|
||||
DreamFrameCounterInfo, DreamBoolToFloat, DreamBoolToInt, DreamSawWave, DreamTriangleWave,
|
||||
DreamTriangleEvent, DreamSmoothEvent, DreamCalculation]
|
||||
DreamTriangleEvent, DreamSmoothEvent, DreamCalculation, DreamImageColorShift,
|
||||
DreamComparePalette, DreamImageContrast, DreamImageBrightness, DreamLogFile,
|
||||
DreamLaboratory, DreamStringToLog, DreamIntToLog, DreamFloatToLog, DreamJoinLog]
|
||||
_SIGNATURE_SUFFIX = " [Dream]"
|
||||
|
||||
MANIFEST = {
|
||||
"name": "Dream Project Animation",
|
||||
"version": (3, 1, 0),
|
||||
"version": (4, 0, 0),
|
||||
"author": "Dream Project",
|
||||
"project": "https://github.com/alt-key-project/comfyui-dream-project",
|
||||
"description": "Various utility nodes for creating animations with ComfyUI",
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ from .shared import hashed_as_strings
|
||||
|
||||
class DreamCalculation:
|
||||
NODE_NAME = "Calculation"
|
||||
ICON = "🖩"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -27,7 +28,7 @@ class DreamCalculation:
|
||||
}
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.ANIMATION_CURVES
|
||||
CATEGORY = NodeCategories.UTILS
|
||||
RETURN_TYPES = ("FLOAT", "INT")
|
||||
RETURN_NAMES = ("FLOAT", "INT")
|
||||
FUNCTION = "result"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .categories import NodeCategories
|
||||
from .shared import *
|
||||
from .types import *
|
||||
@@ -128,7 +129,7 @@ class DreamColorAlign:
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": SharedTypes.palette | {
|
||||
"target_align": (RGBPalette.ID, ),
|
||||
"target_align": (RGBPalette.ID,),
|
||||
"alignment_factor": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 10.0, "step": 0.1}),
|
||||
}
|
||||
}
|
||||
@@ -151,8 +152,8 @@ class DreamColorAlign:
|
||||
for i in range(len(palette)):
|
||||
p = palette[i]
|
||||
t = target_align[i]
|
||||
(_, r1, g1, b1) = p.analyze()
|
||||
(_, r2, g2, b2) = t.analyze()
|
||||
(_, _, r1, g1, b1) = p.analyze()
|
||||
(_, _, r2, g2, b2) = t.analyze()
|
||||
|
||||
dr = (r2 - r1) * alignment_factor
|
||||
dg = (g2 - g1) * alignment_factor
|
||||
@@ -214,9 +215,150 @@ class DreamColorShift:
|
||||
return (tuple(results),)
|
||||
|
||||
|
||||
class DreamImageColorShift:
|
||||
NODE_NAME = "Image Color Shift"
|
||||
ICON = "🖼"
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"image": ("IMAGE",),
|
||||
"red_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0}),
|
||||
"green_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0}),
|
||||
"blue_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0}),
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.IMAGE_COLORS
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "result"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *values):
|
||||
return ALWAYS_CHANGED_FLAG
|
||||
|
||||
def result(self, image, red_multiplier, green_multiplier, blue_multiplier):
|
||||
proc = DreamImageProcessor(inputs=image)
|
||||
|
||||
def recolor(im: DreamImage, *a, **args):
|
||||
return (im.adjust_colors(red_multiplier, green_multiplier, blue_multiplier),)
|
||||
|
||||
return proc.process(recolor)
|
||||
|
||||
|
||||
class DreamImageBrightness:
|
||||
NODE_NAME = "Image Brightness Adjustment"
|
||||
ICON = "☼"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"image": ("IMAGE",),
|
||||
"factor": ("FLOAT", {"default": 1.0, "min": 0.0}),
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.IMAGE_COLORS
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "result"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *values):
|
||||
return ALWAYS_CHANGED_FLAG
|
||||
|
||||
def result(self, image, factor):
|
||||
proc = DreamImageProcessor(inputs=image)
|
||||
|
||||
def change(im: DreamImage, *a, **args):
|
||||
return (im.change_brightness(factor),)
|
||||
|
||||
return proc.process(change)
|
||||
|
||||
|
||||
class DreamImageContrast:
|
||||
NODE_NAME = "Image Contrast Adjustment"
|
||||
ICON = "◐"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"image": ("IMAGE",),
|
||||
"factor": ("FLOAT", {"default": 1.0, "min": 0.0}),
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.IMAGE_COLORS
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "result"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *values):
|
||||
return ALWAYS_CHANGED_FLAG
|
||||
|
||||
def result(self, image, factor):
|
||||
proc = DreamImageProcessor(inputs=image)
|
||||
|
||||
def change(im: DreamImage, *a, **args):
|
||||
return (im.change_contrast(factor),)
|
||||
|
||||
return proc.process(change)
|
||||
|
||||
|
||||
class DreamComparePalette:
|
||||
NODE_NAME = "Compare Palettes"
|
||||
ICON = "📊"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"a": (RGBPalette.ID,),
|
||||
"b": (RGBPalette.ID,),
|
||||
},
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.IMAGE_COLORS
|
||||
RETURN_TYPES = ("FLOAT", "FLOAT", "FLOAT", "FLOAT")
|
||||
RETURN_NAMES = (
|
||||
"brightness_multiplier", "contrast_multiplier", "red_multiplier", "green_multiplier", "blue_multiplier")
|
||||
FUNCTION = "result"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *values):
|
||||
return ALWAYS_CHANGED_FLAG
|
||||
|
||||
def result(self, a, b):
|
||||
MIN_VALUE = 1 / 255.0
|
||||
|
||||
brightness = list()
|
||||
contrasts = list()
|
||||
reds = list()
|
||||
greens = list()
|
||||
blues = list()
|
||||
|
||||
for i in range(min(len(a), len(b))):
|
||||
(bright, ctr, red, green, blue) = a[i].analyze()
|
||||
(bright2, ctr2, red2, green2, blue2) = b[i].analyze()
|
||||
brightness.append(bright2 / max(MIN_VALUE, bright))
|
||||
contrasts.append(ctr2 / max(MIN_VALUE, ctr))
|
||||
reds.append(red2 / max(MIN_VALUE, red))
|
||||
greens.append(green2 / max(MIN_VALUE, green))
|
||||
blues.append(blue2 / max(MIN_VALUE, blue))
|
||||
|
||||
n = len(brightness)
|
||||
|
||||
return (sum(brightness) / n, sum(contrasts) / n, sum(reds) / n,
|
||||
sum(greens) / n, sum(blues) / n)
|
||||
|
||||
|
||||
class DreamAnalyzePalette:
|
||||
NODE_NAME = "Analyze Palette"
|
||||
NODE = "📊"
|
||||
ICON = "📊"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -226,8 +368,8 @@ class DreamAnalyzePalette:
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.IMAGE_COLORS
|
||||
RETURN_TYPES = ("FLOAT", "FLOAT", "FLOAT", "FLOAT")
|
||||
RETURN_NAMES = ("brightness", "redness", "greenness", "blueness")
|
||||
RETURN_TYPES = ("FLOAT", "FLOAT", "FLOAT", "FLOAT", "FLOAT")
|
||||
RETURN_NAMES = ("brightness", "contrast", "redness", "greenness", "blueness")
|
||||
FUNCTION = "result"
|
||||
|
||||
@classmethod
|
||||
@@ -236,12 +378,13 @@ class DreamAnalyzePalette:
|
||||
|
||||
def result(self, palette):
|
||||
f = 1.0 / len(palette)
|
||||
(w, r, g, b) = (0, 0, 0, 0)
|
||||
(w, c, r, g, b) = (0, 0, 0, 0, 0)
|
||||
for p in palette:
|
||||
(brightness, red, green, blue) = p.analyze()
|
||||
(brightness, contrast, red, green, blue) = p.analyze()
|
||||
w += brightness
|
||||
c += contrast
|
||||
r += red
|
||||
g += green
|
||||
b += blue
|
||||
|
||||
return w * f, r * f, g * f, b * f
|
||||
return w * f, c * f, r * f, g * f, b * f
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ EMBEDDED_CONFIGURATION = {
|
||||
"file_extension": "mp4",
|
||||
"path": "ffmpeg",
|
||||
"arguments": ["-r", "%FPS%", "-f", "concat", "-safe", "0", "-vsync",
|
||||
"cfr", "-i", "%FRAMES%", "-c:v", "libx265", "-pix_fmt",
|
||||
"cfr", "-i", "%FRAMES%", "-c:v", "libx264", "-pix_fmt",
|
||||
"yuv420p", "%OUTPUT%"]
|
||||
},
|
||||
"mpeg_coder": {
|
||||
@@ -11,7 +11,7 @@ EMBEDDED_CONFIGURATION = {
|
||||
"bitrate_factor": 1.0,
|
||||
"max_b_frame": 2,
|
||||
"file_extension": "mp4",
|
||||
"codec_name": "libx265"
|
||||
"codec_name": "libx264"
|
||||
},
|
||||
"encoding": {
|
||||
"jpeg_quality": 95
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+100
@@ -0,0 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
|
||||
from .categories import *
|
||||
from .shared import ALWAYS_CHANGED_FLAG, DreamStateFile
|
||||
from .types import *
|
||||
|
||||
_laboratory_state = DreamStateFile("laboratory")
|
||||
|
||||
|
||||
class DreamLaboratory:
|
||||
NODE_NAME = "Laboratory"
|
||||
ICON = "🧪"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": SharedTypes.frame_counter | {
|
||||
"key": ("STRING", {"default": "Random value " + str(random.randint(0, 1000000))}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"renew_policy": (["every frame", "first frame"],),
|
||||
"min_value": ("FLOAT", {"default": 0.0}),
|
||||
"max_value": ("FLOAT", {"default": 1.0}),
|
||||
"mode": (["random uniform", "random bell", "ladder", "random walk"],),
|
||||
},
|
||||
"optional": {
|
||||
"step_size": ("FLOAT", {"default": 0.1}),
|
||||
},
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.UTILS
|
||||
RETURN_TYPES = ("FLOAT", "INT", LogEntry.ID)
|
||||
RETURN_NAMES = ("FLOAT", "INT", "log_entry")
|
||||
FUNCTION = "result"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *values):
|
||||
return ALWAYS_CHANGED_FLAG
|
||||
|
||||
def _generate(self, seed, last_value, min_value, max_value, mode, step_size):
|
||||
rnd = random.Random()
|
||||
rnd.seed(seed)
|
||||
|
||||
def jsonify(v: float):
|
||||
return json.loads(json.dumps(v))
|
||||
|
||||
if mode == "random uniform":
|
||||
return jsonify(self._mode_uniform(rnd, last_value, min_value, max_value, step_size))
|
||||
elif mode == "random bell":
|
||||
return jsonify(self._mode_bell(rnd, last_value, min_value, max_value, step_size))
|
||||
elif mode == "ladder":
|
||||
return jsonify(self._mode_ladder(rnd, last_value, min_value, max_value, step_size))
|
||||
else:
|
||||
return jsonify(self._mode_walk(rnd, last_value, min_value, max_value, step_size))
|
||||
|
||||
def _mode_uniform(self, rnd: random.Random, last_value: float, min_value: float, max_value: float, step_size):
|
||||
return rnd.random() * (max_value - min_value) + min_value
|
||||
|
||||
def _mode_bell(self, rnd: random.Random, last_value: float, min_value: float, max_value: float, step_size):
|
||||
s = 0.0
|
||||
for i in range(3):
|
||||
s += rnd.random() * (max_value - min_value) + min_value
|
||||
return s / 3.0
|
||||
|
||||
def _mode_ladder(self, rnd: random.Random, last_value: float, min_value: float, max_value: float, step_size):
|
||||
if last_value is None:
|
||||
last_value = min_value - step_size
|
||||
next_value = last_value + step_size
|
||||
if next_value > max_value:
|
||||
d = abs(max_value - min_value)
|
||||
next_value = (next_value - min_value) % d + min_value
|
||||
return next_value
|
||||
|
||||
def _mode_walk(self, rnd: random.Random, last_value: float, min_value: float, max_value: float, step_size):
|
||||
if last_value is None:
|
||||
last_value = (max_value - min_value) * 0.5
|
||||
if rnd.random() >= 0.5:
|
||||
return min(max_value, last_value + step_size)
|
||||
else:
|
||||
return max(min_value, last_value - step_size)
|
||||
|
||||
def result(self, key, frame_counter: FrameCounter, seed, renew_policy, min_value, max_value, mode, **values):
|
||||
if min_value > max_value:
|
||||
t = max_value
|
||||
max_value = min_value
|
||||
min_value = t
|
||||
step_size = values.get("step_size", abs(max_value - min_value) * 0.1)
|
||||
last_value = _laboratory_state.get_section("values").get(key, None)
|
||||
|
||||
if (last_value is None) or (renew_policy == "every frame") or frame_counter.is_first_frame:
|
||||
v = _laboratory_state.get_section("values") \
|
||||
.update(key, 0, lambda old: self._generate(seed, last_value, min_value, max_value, mode, step_size))
|
||||
return v, round(v), LogEntry.new(
|
||||
"Laboratory generated new value for '{}': {} ({})".format(key, v, round(v)))
|
||||
else:
|
||||
return last_value, round(last_value), LogEntry.new("Laboratory reused value for '{}': {} ({})"
|
||||
.format(key, last_value, round(last_value)))
|
||||
+12
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Analyze Palette [Dream]": "Output brightness, red, green and blue averages of a palette",
|
||||
"Analyze Palette [Dream]": "Output brightness, contrast, red, green and blue averages of a palette",
|
||||
"Beat Curve [Dream]": "Beat pattern curve with impulses at specified beats of a measure",
|
||||
"Big Float Switch [Dream]": "Switch for up to 10 inputs",
|
||||
"Big Image Switch [Dream]": "Switch for up to 10 inputs",
|
||||
@@ -14,22 +14,31 @@
|
||||
"CSV Generator [Dream]": "CSV output, mainly for debugging purposes",
|
||||
"Calculation [Dream]": "Mathematical calculation node",
|
||||
"Common Frame Dimensions [Dream]": "Utility for calculating good width/height based on common video dimensions",
|
||||
"Compare Palettes [Dream]": "Analyses two palettes producing the factor for each color channel",
|
||||
"FFMPEG Video Encoder [Dream]": "Post processing for animation sequences calling FFMPEG to generate video file",
|
||||
"File Count [Dream]": "Finds the number of files in a directory matching specified patterns",
|
||||
"Finalize Prompt [Dream]": "Used in conjunction with 'Build Prompt'",
|
||||
"Float Input [Dream]": "Float input (until primitive routing issues are solved)",
|
||||
"Float to Log Entry [Dream]": "Logging for float values",
|
||||
"Frame Count Calculator [Dream]": "Simple utility to calculate number of frames based on duration and framerate",
|
||||
"Frame Counter (Directory) [Dream]": "Directory backed frame counter, for output directories",
|
||||
"Frame Counter (Simple) [Dream]": "Integer value used as frame counter",
|
||||
"Frame Counter Info [Dream]": "Extracts information from the frame counter",
|
||||
"Frame Counter Offset [Dream]": "Adds an offset to a frame counter",
|
||||
"Image Brightness Adjustment [Dream]": "Adjusts the brightness of an image by a factor",
|
||||
"Image Color Shift [Dream]": "Adjust the colors (or brightness) of an image",
|
||||
"Image Contrast Adjustment [Dream]": "Adjusts the contrast of an image by a factor",
|
||||
"Image Motion [Dream]": "Node supporting zooming in/out and translating an image",
|
||||
"Image Sequence Blend [Dream]": "Post processing for animation sequences blending frame for a smoother blurred effect",
|
||||
"Image Sequence Loader [Dream]": "Loads a frame from a directory of images",
|
||||
"Image Sequence Saver [Dream]": "Saves a frame to a directory",
|
||||
"Image Sequence Tweening [Dream]": "Post processing for animation sequences generating blended in-between frames",
|
||||
"Int Input [Dream]": "Integer input (until primitive routing issues are solved)",
|
||||
"Int to Log Entry [Dream]": "Logging for int values",
|
||||
"Laboratory [Dream]": "Super-charged number generator for experimenting with ComfyUI",
|
||||
"Linear Curve [Dream]": "Linear interpolation between two value over the full animation",
|
||||
"Log Entry Joiner [Dream]": "Merges multiple log entries (reduces noodling)",
|
||||
"Log File [Dream]": "Logging node for output to file",
|
||||
"Noise from Area Palettes [Dream]": "Generates noise based on the colors of up to nine different palettes",
|
||||
"Noise from Palette [Dream]": "Generates noise based on the colors in a palette",
|
||||
"Palette Color Align [Dream]": "Shifts the colors of one palette towards another target palette",
|
||||
@@ -40,8 +49,9 @@
|
||||
"Sine Curve [Dream]": "Simple sine wave curve",
|
||||
"Smooth Event Curve [Dream]": "Single event/peak curve with a slight bell-shape",
|
||||
"String Input [Dream]": "String input (until primitive routing issues are solved)",
|
||||
"String to Log Entry [Dream]": "Use any string as a log entry",
|
||||
"Text Input [Dream]": "Multiline string input (until primitive routing issues are solved)",
|
||||
"Triangle Curve [Dream]": "Triangle wave curve",
|
||||
"Triangle Event Curve [Dream]": "Single event/peak curve with triangular shape",
|
||||
"Video Encoder (mpegCoder) [Dream]": "Post processing for animation sequences using mpegCoder module to generate video file"
|
||||
} and switches.
|
||||
}
|
||||
@@ -8,7 +8,7 @@ from PIL.PngImagePlugin import PngInfo
|
||||
from .categories import NodeCategories
|
||||
from .shared import hashed_as_strings, DreamImageProcessor, DreamImage, \
|
||||
list_images_in_directory, DreamConfig
|
||||
from .types import SharedTypes, FrameCounter, AnimationSequence
|
||||
from .types import SharedTypes, FrameCounter, AnimationSequence, LogEntry
|
||||
|
||||
CONFIG = DreamConfig()
|
||||
|
||||
@@ -42,7 +42,7 @@ class DreamImageSequenceOutput:
|
||||
"directory_path": ("STRING", {"default": comfy_paths.output_directory, "multiline": False}),
|
||||
"prefix": ("STRING", {"default": 'frame', "multiline": False}),
|
||||
"digits": ("INT", {"default": 5}),
|
||||
"at_end": (["stop output", "keep going"],),
|
||||
"at_end": (["stop output", "raise error", "keep going"],),
|
||||
"filetype": (['png with embedded workflow', "png", 'jpg'],),
|
||||
},
|
||||
"hidden": {
|
||||
@@ -52,9 +52,9 @@ class DreamImageSequenceOutput:
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.IMAGE_ANIMATION
|
||||
RETURN_TYPES = (AnimationSequence.ID,)
|
||||
RETURN_TYPES = (AnimationSequence.ID, LogEntry.ID)
|
||||
OUTPUT_NODE = True
|
||||
RETURN_NAMES = ("sequence",)
|
||||
RETURN_NAMES = ("sequence", "log_entry")
|
||||
FUNCTION = "save"
|
||||
|
||||
@classmethod
|
||||
@@ -64,11 +64,16 @@ class DreamImageSequenceOutput:
|
||||
def _get_new_filename(self, current_frame, prefix, digits, filetype):
|
||||
return prefix + "_" + str(current_frame).zfill(digits) + "." + filetype.split(" ")[0]
|
||||
|
||||
def _save_single_image(self, dream_image: DreamImage, batch_counter, frame_counter: FrameCounter, directory_path,
|
||||
prefix, digits, filetype, prompt, extra_pnginfo, at_end):
|
||||
def _save_single_image(self, dream_image: DreamImage, batch_counter, frame_counter: FrameCounter,
|
||||
directory_path,
|
||||
prefix, digits, filetype, prompt, extra_pnginfo, at_end, logger):
|
||||
|
||||
if at_end == "stop output" and frame_counter.is_after_last_frame:
|
||||
print("Reached end of animation - not saving output!")
|
||||
logger("Reached end of animation - not saving output!")
|
||||
return ()
|
||||
if at_end == "raise error" and frame_counter.is_after_last_frame:
|
||||
logger("Reached end of animation - raising error to stop processing!")
|
||||
raise Exception("Reached end of animation!")
|
||||
filename = self._get_new_filename(frame_counter.current_frame, prefix, digits, filetype)
|
||||
if batch_counter >= 0:
|
||||
filepath = os.path.join(directory_path, "batch_" + (str(batch_counter).zfill(4)), filename)
|
||||
@@ -81,7 +86,7 @@ class DreamImageSequenceOutput:
|
||||
dream_image.save_png(filepath, filetype == 'png with embedded workflow', prompt, extra_pnginfo)
|
||||
elif filetype == "jpg":
|
||||
dream_image.save_jpg(filepath, int(CONFIG.get("encoding.jpeg_quality", 95)))
|
||||
print("Saved {} in {}".format(filename, os.path.abspath(save_dir)))
|
||||
logger("Saved {} in {}".format(filename, os.path.abspath(save_dir)))
|
||||
return ()
|
||||
|
||||
def _generate_animation_sequence(self, filetype, directory_path, frame_counter):
|
||||
@@ -93,13 +98,19 @@ class DreamImageSequenceOutput:
|
||||
return AnimationSequence(frame_counter, frames)
|
||||
|
||||
def save(self, image, **args):
|
||||
log_texts = list()
|
||||
logger = lambda s: log_texts.append(s)
|
||||
if not args.get("directory_path", ""):
|
||||
args["directory_path"] = comfy_paths.output_directory
|
||||
args["logger"] = logger
|
||||
proc = DreamImageProcessor(image, **args)
|
||||
proc.process(self._save_single_image)
|
||||
frame_counter: FrameCounter = args["frame_counter"]
|
||||
log_entry = LogEntry([])
|
||||
for text in log_texts:
|
||||
log_entry = log_entry.add(text)
|
||||
if frame_counter.is_final_frame:
|
||||
return (self._generate_animation_sequence(args["filetype"], args["directory_path"],
|
||||
frame_counter),)
|
||||
frame_counter), log_entry)
|
||||
else:
|
||||
return (AnimationSequence(frame_counter),)
|
||||
return (AnimationSequence(frame_counter), log_entry)
|
||||
|
||||
@@ -147,6 +147,9 @@ Mathematical calculation node. Exposes most of the mathematical functions in the
|
||||
[math module](https://docs.python.org/3/library/math.html), mathematical operators as well as round, abs, int,
|
||||
float, max and min.
|
||||
|
||||
### Compare Palettes [Dream]
|
||||
Analyses two palettes and produces the quotient for each individual channel (b/a) and brightness.
|
||||
|
||||
### CSV Curve [Dream]
|
||||
CSV input curve where first column is frame or second and second column is value.
|
||||
|
||||
@@ -166,6 +169,9 @@ Post processing for animation sequences using the python module mpegCoder with f
|
||||
### File Count [Dream]
|
||||
Finds the number of files in a directory matching specified patterns.
|
||||
|
||||
### Float/Int/string to Log Entry [Dream]
|
||||
Logging for float/int/string values.
|
||||
|
||||
### Frame Count Calculator [Dream]
|
||||
Simple utility to calculate number of frames based on time and framerate.
|
||||
|
||||
@@ -182,6 +188,15 @@ Extracts information from the frame counter.
|
||||
### Frame Counter Offset [Dream]
|
||||
Adds an offset to a frame counter.
|
||||
|
||||
### Image Brightness Adjustment [Dream]
|
||||
Adjusts the brightness of an image by a factor.
|
||||
|
||||
### Image Color Shift [Dream]
|
||||
Allows changing the colors of an image with a multiplier for each channel (RGB).
|
||||
|
||||
### Image Contrast Adjustment [Dream]
|
||||
Adjusts the contrast of an image by a factor.
|
||||
|
||||
### Image Motion [Dream]
|
||||
Node supporting zooming in/out and translating an image.
|
||||
|
||||
@@ -197,6 +212,15 @@ Saves a frame to a directory.
|
||||
### Image Sequence Tweening [Dream]
|
||||
Post processing for animation sequences generating blended in-between frames.
|
||||
|
||||
### Laboratory [Dream]
|
||||
Super-charged number generator for experimenting with ComfyUI.
|
||||
|
||||
### Log Entry Joiner [Dream]
|
||||
Merges multiple log entries (reduces noodling).
|
||||
|
||||
### Log File [Dream]
|
||||
The text logging facility for the Dream Project Animation nodes.
|
||||
|
||||
### Linear Curve [Dream]
|
||||
Linear interpolation between two values over the full animation.
|
||||
|
||||
@@ -262,6 +286,12 @@ This flow demonstrates sampling image areas into palettes and generating noise f
|
||||
|
||||
[area-sampled-noise](examples/area-sampled-noise.json)
|
||||
|
||||
### Prompt Morphing
|
||||
|
||||
This flow demonstrates prompt building with weights based on curves and brightness and contrast control.
|
||||
|
||||
[prompt-morphing](examples/prompt-morphing.json)
|
||||
|
||||
## Known issues
|
||||
|
||||
### FFMPEG
|
||||
|
||||
+18
-12
@@ -5,7 +5,7 @@ import subprocess
|
||||
import tempfile
|
||||
from functools import lru_cache
|
||||
|
||||
from PIL import Image
|
||||
from PIL import Image as PilImage
|
||||
|
||||
from .categories import NodeCategories
|
||||
from .err import on_error
|
||||
@@ -16,8 +16,8 @@ CONFIG = DreamConfig()
|
||||
|
||||
|
||||
@lru_cache(5)
|
||||
def _load_image_cached(filename) -> Image:
|
||||
return Image.open(filename)
|
||||
def _load_image_cached(filename):
|
||||
return PilImage.open(filename)
|
||||
|
||||
|
||||
class TempFileSet:
|
||||
@@ -136,8 +136,8 @@ class DreamVideoEncoderMpegCoder:
|
||||
NODE_NAME = "Video Encoder (mpegCoder)"
|
||||
ICON = "🎬"
|
||||
CATEGORY = NodeCategories.ANIMATION_POSTPROCESSING
|
||||
RETURN_TYPES = ()
|
||||
RETURN_NAMES = ()
|
||||
RETURN_TYPES = (LogEntry.ID,)
|
||||
RETURN_NAMES = ("log_entry",)
|
||||
OUTPUT_NODE = True
|
||||
FUNCTION = "encode"
|
||||
|
||||
@@ -164,9 +164,10 @@ class DreamVideoEncoderMpegCoder:
|
||||
|
||||
def encode(self, sequence, name, framerate_factor, remove_images):
|
||||
if not sequence.is_defined:
|
||||
return ()
|
||||
return (LogEntry([]),)
|
||||
config = DreamConfig()
|
||||
filename = _make_video_filename(name, config.get("mpeg_coder.file_extension", "mp4"))
|
||||
log_entry = LogEntry([])
|
||||
for batch_num in sequence.batches:
|
||||
try:
|
||||
images = list(sequence.get_image_files_of_batch(batch_num))
|
||||
@@ -182,13 +183,14 @@ class DreamVideoEncoderMpegCoder:
|
||||
fps=sequence.fps * framerate_factor,
|
||||
codec_name=config.get("mpeg_coder.codec_name", "libx265"))
|
||||
enc.encode()
|
||||
log_entry = log_entry.add("Generated video '{}'".format(filename))
|
||||
if remove_images:
|
||||
for imagepath in images:
|
||||
if os.path.isfile(imagepath):
|
||||
os.unlink(imagepath)
|
||||
except Exception as e:
|
||||
on_error(self.__class__, str(e))
|
||||
return ()
|
||||
return (log_entry,)
|
||||
|
||||
|
||||
class DreamVideoEncoder:
|
||||
@@ -207,8 +209,8 @@ class DreamVideoEncoder:
|
||||
}
|
||||
|
||||
CATEGORY = NodeCategories.ANIMATION_POSTPROCESSING
|
||||
RETURN_TYPES = ()
|
||||
RETURN_NAMES = ()
|
||||
RETURN_TYPES = (LogEntry.ID,)
|
||||
RETURN_NAMES = ("log_entry",)
|
||||
OUTPUT_NODE = True
|
||||
FUNCTION = "encode"
|
||||
|
||||
@@ -230,24 +232,28 @@ class DreamVideoEncoder:
|
||||
def generate_video(self, files, fps, filename, config):
|
||||
filename = self._find_free_filename(filename, os.path.dirname(files[0]))
|
||||
_ffmpeg(config, files, fps, filename)
|
||||
return filename
|
||||
|
||||
def encode(self, sequence: AnimationSequence, name: str, remove_images, framerate_factor):
|
||||
if not sequence.is_defined:
|
||||
return ()
|
||||
return (LogEntry([]),)
|
||||
|
||||
config = DreamConfig()
|
||||
filename = _make_video_filename(name, config.get("ffmpeg.file_extension", "mp4"))
|
||||
log_entry = LogEntry([])
|
||||
for batch_num in sequence.batches:
|
||||
try:
|
||||
images = list(sequence.get_image_files_of_batch(batch_num))
|
||||
self.generate_video(images, sequence.fps * framerate_factor, filename, config)
|
||||
actual_filename = self.generate_video(images, sequence.fps * framerate_factor, filename, config)
|
||||
|
||||
log_entry = log_entry.add("Generated video '{}'".format(actual_filename))
|
||||
if remove_images:
|
||||
for imagepath in images:
|
||||
if os.path.isfile(imagepath):
|
||||
os.unlink(imagepath)
|
||||
except Exception as e:
|
||||
on_error(self.__class__, str(e))
|
||||
return ()
|
||||
return (log_entry,)
|
||||
|
||||
|
||||
class DreamSequenceTweening:
|
||||
|
||||
@@ -10,13 +10,13 @@ import folder_paths as comfy_paths
|
||||
import glob
|
||||
import numpy
|
||||
import torch
|
||||
from PIL import Image, ImageFilter
|
||||
from PIL import Image, ImageFilter, ImageEnhance
|
||||
from PIL.ImageDraw import ImageDraw
|
||||
from PIL.PngImagePlugin import PngInfo
|
||||
from .embedded_config import EMBEDDED_CONFIGURATION
|
||||
from typing import Dict, Tuple, List
|
||||
|
||||
from .dreamlogger import DreamLog
|
||||
from .embedded_config import EMBEDDED_CONFIGURATION
|
||||
|
||||
NODE_FILE = os.path.abspath(__file__)
|
||||
DREAM_NODES_SOURCE_ROOT = os.path.dirname(NODE_FILE)
|
||||
@@ -151,6 +151,14 @@ class DreamImage:
|
||||
self.size = self.pil_image.size
|
||||
self._draw = ImageDraw(self.pil_image)
|
||||
|
||||
def change_brightness(self, factor):
|
||||
enhancer = ImageEnhance.Brightness(self.pil_image)
|
||||
return DreamImage(pil_image=enhancer.enhance(factor))
|
||||
|
||||
def change_contrast(self, factor):
|
||||
enhancer = ImageEnhance.Contrast(self.pil_image)
|
||||
return DreamImage(pil_image=enhancer.enhance(factor))
|
||||
|
||||
def numpy_array(self):
|
||||
return numpy.array(self.pil_image)
|
||||
|
||||
@@ -195,6 +203,15 @@ class DreamImage:
|
||||
def blur(self, amount):
|
||||
return DreamImage(pil_image=self.pil_image.filter(ImageFilter.GaussianBlur(amount)))
|
||||
|
||||
def adjust_colors(self, red_factor=1.0, green_factor=1.0, blue_factor=1.0):
|
||||
# newRed = 1.1*oldRed + 0*oldGreen + 0*oldBlue + constant
|
||||
# newGreen = 0*oldRed + 0.9*OldGreen + 0*OldBlue + constant
|
||||
# newBlue = 0*oldRed + 0*OldGreen + 1*OldBlue + constant
|
||||
matrix = (red_factor, 0, 0, 0,
|
||||
0, green_factor, 0, 0,
|
||||
0, 0, blue_factor, 0)
|
||||
return DreamImage(pil_image=self.pil_image.convert("RGB", matrix))
|
||||
|
||||
def get_pixel(self, x, y):
|
||||
p = self.pil_image.getpixel((x, y))
|
||||
if len(p) == 4:
|
||||
@@ -315,9 +332,9 @@ class DreamStateStore:
|
||||
|
||||
|
||||
class DreamStateFile:
|
||||
def __init__(self, state_file_path=os.path.join(TEMP_PATH, "state.json")):
|
||||
self._dirname = os.path.dirname(state_file_path)
|
||||
self._filepath = state_file_path
|
||||
def __init__(self, state_collection_name="state"):
|
||||
self._filepath = os.path.join(TEMP_PATH, state_collection_name+".json")
|
||||
self._dirname = os.path.dirname(self._filepath)
|
||||
if not os.path.isdir(self._dirname):
|
||||
os.makedirs(self._dirname)
|
||||
if not os.path.isfile(self._filepath):
|
||||
@@ -341,7 +358,6 @@ class DreamStateFile:
|
||||
self._data[key] = value
|
||||
with open(self._filepath, "w", encoding="utf-8") as f:
|
||||
json.dump(self._data, f)
|
||||
print("* {} -> {}".format(key, value))
|
||||
return previous
|
||||
|
||||
|
||||
@@ -360,7 +376,7 @@ class MpegEncoderUtility:
|
||||
self._logger = get_logger()
|
||||
self._enc = mpegCoder.MpegEncoder()
|
||||
bit_rate = self._calculate_bit_rate(width, height, fps, bit_rate_factor)
|
||||
self._logger.info("Bitrate "+str(bit_rate))
|
||||
self._logger.info("Bitrate " + str(bit_rate))
|
||||
self._enc.setParameter(
|
||||
videoPath=video_path, codecName=codec_name,
|
||||
nthread=encoding_threads, bitRate=bit_rate, width=width, height=height, widthSrc=width,
|
||||
@@ -368,7 +384,7 @@ class MpegEncoderUtility:
|
||||
GOPSize=len(files), maxBframe=max_b_frame, frameRate=self._fps_to_tuple(fps))
|
||||
|
||||
def _calculate_bit_rate(self, width: int, height: int, fps: float, bit_rate_factor: float):
|
||||
bits_per_pixel_base = 0.075
|
||||
bits_per_pixel_base = 0.5
|
||||
return round(max(10, float(width * height * fps * bits_per_pixel_base * bit_rate_factor * 0.001)))
|
||||
|
||||
def encode(self):
|
||||
@@ -390,6 +406,7 @@ class MpegEncoderUtility:
|
||||
def _fps_to_tuple(self, fps: float):
|
||||
def _is_almost_int(f: float):
|
||||
return abs(f - int(f)) < 0.001
|
||||
|
||||
a = fps
|
||||
b = 1
|
||||
while not _is_almost_int(a) and b < 100:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import random
|
||||
import time
|
||||
|
||||
from typing import List, Dict
|
||||
from typing import List, Dict, Tuple
|
||||
|
||||
from .shared import DreamImage
|
||||
|
||||
@@ -26,6 +26,24 @@ class RGBPalette:
|
||||
for c in colors:
|
||||
self._colors.append(_fix_tuple(c))
|
||||
|
||||
def _calculate_channel_contrast(self, c):
|
||||
hist = list(map(lambda _: 0, range(16)))
|
||||
for pixel in self._colors:
|
||||
hist[pixel[c] // 16] += 1
|
||||
s = 0
|
||||
max_possible = (15 - 0) * (len(self) // 2) * (len(self) // 2)
|
||||
for i in range(16):
|
||||
for j in range(i):
|
||||
if i != j:
|
||||
s += abs(i - j) * hist[i] * hist[j]
|
||||
return s / max_possible
|
||||
|
||||
def _calculate_combined_contrast(self):
|
||||
s = 0
|
||||
for c in range(3):
|
||||
s += self._calculate_channel_contrast(c)
|
||||
return s / 3
|
||||
|
||||
def analyze(self):
|
||||
total_red = 0
|
||||
total_blue = 0
|
||||
@@ -38,7 +56,7 @@ class RGBPalette:
|
||||
r = float(total_red) / (255 * n)
|
||||
g = float(total_green) / (255 * n)
|
||||
b = float(total_blue) / (255 * n)
|
||||
return ((r + g + b) / 3.0, r, g, b)
|
||||
return ((r + g + b) / 3.0, self._calculate_combined_contrast(), r, g, b)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._colors)
|
||||
@@ -73,7 +91,12 @@ class PartialPrompt:
|
||||
def add(self, text: str, weight: float):
|
||||
output = PartialPrompt()
|
||||
output._data = dict(self._data)
|
||||
output._data[text.strip()] = weight
|
||||
for parts in text.split(","):
|
||||
parts = parts.strip()
|
||||
if " " in parts:
|
||||
output._data["(" + parts + ")"] = weight
|
||||
else:
|
||||
output._data[parts] = weight
|
||||
return output
|
||||
|
||||
def is_empty(self):
|
||||
@@ -110,6 +133,35 @@ class PartialPrompt:
|
||||
return ", ".join(pos), ", ".join(neg)
|
||||
|
||||
|
||||
class LogEntry:
|
||||
ID = "LOG_ENTRY"
|
||||
|
||||
@classmethod
|
||||
def new(cls, text):
|
||||
return LogEntry([(time.time(), text)])
|
||||
|
||||
def __init__(self, data: List[Tuple[float, str]] = None):
|
||||
if data is None:
|
||||
self._data = list()
|
||||
else:
|
||||
self._data = list(data)
|
||||
|
||||
def add(self, text: str):
|
||||
new_data = list(self._data)
|
||||
new_data.append((time.time(), text))
|
||||
return LogEntry(new_data)
|
||||
|
||||
def merge(self, log_entry):
|
||||
new_data = list(self._data)
|
||||
new_data.extend(log_entry._data)
|
||||
return LogEntry(new_data)
|
||||
|
||||
def get_filtered_entries(self, t: float):
|
||||
for d in sorted(self._data):
|
||||
if d[0] > t:
|
||||
yield d
|
||||
|
||||
|
||||
class FrameCounter:
|
||||
ID = "FRAME_COUNTER"
|
||||
|
||||
|
||||
+180
-2
@@ -1,8 +1,187 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import math
|
||||
import os
|
||||
|
||||
import folder_paths as comfy_paths
|
||||
|
||||
from .categories import NodeCategories
|
||||
from .shared import hashed_as_strings
|
||||
from .shared import hashed_as_strings, DreamStateFile
|
||||
from .types import LogEntry, SharedTypes, FrameCounter
|
||||
|
||||
_logfile_state = DreamStateFile("logging")
|
||||
|
||||
|
||||
class DreamJoinLog:
|
||||
NODE_NAME = "Log Entry Joiner"
|
||||
ICON = "🗎"
|
||||
CATEGORY = NodeCategories.UTILS
|
||||
RETURN_TYPES = (LogEntry.ID,)
|
||||
RETURN_NAMES = ("log_entry",)
|
||||
FUNCTION = "convert"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"optional": {
|
||||
"entry_0": (LogEntry.ID,),
|
||||
"entry_1": (LogEntry.ID,),
|
||||
"entry_2": (LogEntry.ID,),
|
||||
"entry_3": (LogEntry.ID,),
|
||||
}
|
||||
}
|
||||
|
||||
def convert(self, **values):
|
||||
entry = LogEntry([])
|
||||
for i in range(4):
|
||||
txt = values.get("entry_" + str(i), None)
|
||||
if txt:
|
||||
entry = entry.merge(txt)
|
||||
return (entry,)
|
||||
|
||||
|
||||
class DreamFloatToLog:
|
||||
NODE_NAME = "Float to Log Entry"
|
||||
ICON = "🗎"
|
||||
CATEGORY = NodeCategories.UTILS
|
||||
RETURN_TYPES = (LogEntry.ID,)
|
||||
RETURN_NAMES = ("log_entry",)
|
||||
FUNCTION = "convert"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"value": ("FLOAT", {"default": 0}),
|
||||
"label": ("STRING", {"default": ""}),
|
||||
},
|
||||
}
|
||||
|
||||
def convert(self, label, value):
|
||||
return (LogEntry.new(label + ": " + str(value)),)
|
||||
|
||||
|
||||
class DreamIntToLog:
|
||||
NODE_NAME = "Int to Log Entry"
|
||||
ICON = "🗎"
|
||||
CATEGORY = NodeCategories.UTILS
|
||||
RETURN_TYPES = (LogEntry.ID,)
|
||||
RETURN_NAMES = ("log_entry",)
|
||||
FUNCTION = "convert"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"value": ("INT", {"default": 0}),
|
||||
"label": ("STRING", {"default": ""}),
|
||||
},
|
||||
}
|
||||
|
||||
def convert(self, label, value):
|
||||
return (LogEntry.new(label + ": " + str(value)),)
|
||||
|
||||
|
||||
class DreamStringToLog:
|
||||
NODE_NAME = "String to Log Entry"
|
||||
ICON = "🗎"
|
||||
OUTPUT_NODE = True
|
||||
CATEGORY = NodeCategories.UTILS
|
||||
RETURN_TYPES = (LogEntry.ID,)
|
||||
RETURN_NAMES = ("log_entry",)
|
||||
FUNCTION = "convert"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"text": ("STRING", {"default": ""}),
|
||||
},
|
||||
}
|
||||
|
||||
def convert(self, text):
|
||||
return (LogEntry.new(text),)
|
||||
|
||||
|
||||
class DreamLogFile:
|
||||
NODE_NAME = "Log File"
|
||||
ICON = "🗎"
|
||||
OUTPUT_NODE = True
|
||||
CATEGORY = NodeCategories.UTILS
|
||||
RETURN_TYPES = ()
|
||||
RETURN_NAMES = ()
|
||||
FUNCTION = "write"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": SharedTypes.frame_counter | {
|
||||
"log_directory": ("STRING", {"default": comfy_paths.output_directory}),
|
||||
"log_filename": ("STRING", {"default": "dreamlog.txt"}),
|
||||
"stdout": ("BOOLEAN", {"default": True}),
|
||||
"active": ("BOOLEAN", {"default": True}),
|
||||
"clock_has_24_hours": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
"optional": {
|
||||
"entry_0": (LogEntry.ID,),
|
||||
"entry_1": (LogEntry.ID,),
|
||||
"entry_2": (LogEntry.ID,),
|
||||
"entry_3": (LogEntry.ID,),
|
||||
"entry_4": (LogEntry.ID,),
|
||||
"entry_5": (LogEntry.ID,),
|
||||
"entry_6": (LogEntry.ID,),
|
||||
"entry_7": (LogEntry.ID,),
|
||||
},
|
||||
}
|
||||
|
||||
def _path_to_log_file(self, log_directory, logfile):
|
||||
if os.path.isabs(logfile):
|
||||
return os.path.normpath(os.path.abspath(logfile))
|
||||
elif os.path.isabs(log_directory):
|
||||
return os.path.normpath(os.path.abspath(os.path.join(log_directory, logfile)))
|
||||
elif log_directory:
|
||||
return os.path.normpath(os.path.abspath(os.path.join(comfy_paths.output_directory, log_directory, logfile)))
|
||||
else:
|
||||
return os.path.normpath(os.path.abspath(os.path.join(comfy_paths.output_directory, logfile)))
|
||||
|
||||
def _get_tm_format(self, clock_has_24_hours):
|
||||
if clock_has_24_hours:
|
||||
return "%a %H:%M:%S"
|
||||
else:
|
||||
return "%a %I:%M:%S %p"
|
||||
|
||||
def write(self, frame_counter: FrameCounter, log_directory, log_filename, stdout, active, clock_has_24_hours,
|
||||
**entries):
|
||||
if not active:
|
||||
return ()
|
||||
log_entry = None
|
||||
for i in range(8):
|
||||
e = entries.get("entry_" + str(i), None)
|
||||
if e is not None:
|
||||
if log_entry is None:
|
||||
log_entry = e
|
||||
else:
|
||||
log_entry = log_entry.merge(e)
|
||||
log_file_path = self._path_to_log_file(log_directory, log_filename)
|
||||
ts = _logfile_state.get_section("timestamps").get(log_file_path, 0)
|
||||
output_text = list()
|
||||
last_t = 0
|
||||
for (t, text) in log_entry.get_filtered_entries(ts):
|
||||
dt = datetime.datetime.fromtimestamp(t)
|
||||
output_text.append("[frame {}/{} (~{}%), timestamp {}]\n{}".format(frame_counter.current_frame + 1,
|
||||
frame_counter.total_frames,
|
||||
round(frame_counter.progress * 100),
|
||||
dt.strftime(self._get_tm_format(
|
||||
clock_has_24_hours)), text.rstrip()))
|
||||
output_text.append("---")
|
||||
last_t = max(t, last_t)
|
||||
output_text = "\n".join(output_text) + "\n"
|
||||
if stdout:
|
||||
print(output_text)
|
||||
with open(log_file_path, "a", encoding="utf-8") as f:
|
||||
f.write(output_text)
|
||||
_logfile_state.get_section("timestamps").update(log_file_path, 0, lambda _: last_t)
|
||||
return ()
|
||||
|
||||
|
||||
def _align_num(n: int, alignment: int, type: str):
|
||||
@@ -52,4 +231,3 @@ class DreamFrameDimensions:
|
||||
return (width, height, final_width, final_height)
|
||||
else:
|
||||
return (height, width, final_height, final_width)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user