Skip to content

Commit 8adcce5

Browse files
committed
Fix frame images timestamp input validation and parsing
Use FLOAT for timestamp fields, handle invalid strings gracefully, update node description, and reset empty timestamp values in the UI when Use Timestamp is disabled.
1 parent bf3f59b commit 8adcce5

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

clientlibs/utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5042,6 +5042,13 @@ function videoInputsFrameToggleHandler(frameImagesNode) {
50425042
function toggleEnabled() {
50435043
const enabled = useWidget.value === true;
50445044

5045+
// FLOAT timestamp widgets: avoid '' on disabled slots (ComfyUI validation error)
5046+
if (!enabled && paramName && paramName.startsWith("timestamp")) {
5047+
if (paramWidget.value === "" || paramWidget.value == null) {
5048+
paramWidget.value = 0.0;
5049+
}
5050+
}
5051+
50455052
if (paramWidget.inputEl) {
50465053
paramWidget.inputEl.disabled = !enabled;
50475054
paramWidget.inputEl.style.opacity = enabled ? "1" : "0.5";

modules/videoInputsFrame.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ def INPUT_TYPES(cls):
2727
"tooltip": "Enable to set a timestamp (seconds) within the input video.",
2828
"default": False,
2929
})
30-
optionalInputs[f"timestamp{i}"] = ("STRING", {
31-
"default": "0",
30+
optionalInputs[f"timestamp{i}"] = ("FLOAT", {
31+
"default": 0.0,
32+
"min": 0.0,
33+
"max": 9999.0,
34+
"step": 0.01,
3235
"tooltip": "Timestamp in seconds (hundredths supported, e.g. 3.44). Only used when 'Use Timestamp' is enabled.",
3336
})
3437

@@ -39,7 +42,7 @@ def INPUT_TYPES(cls):
3942

4043
DESCRIPTION = (
4144
"Build inputs.frameImages entries for video inference: "
42-
"{image: base64}, {image: base64, frame: first|last|<int>}, or "
45+
"{image: base64}, {image: base64, frame: first|last}, or "
4346
"{image: base64, timestamp: seconds}."
4447
)
4548
FUNCTION = "createFrameInputs"
@@ -58,7 +61,7 @@ def createFrameInputs(self, **kwargs):
5861
use_frame = kwargs.get(f"useFrame{i}", False)
5962
frame_position = kwargs.get(f"frame{i} position", "first")
6063
use_timestamp = kwargs.get(f"useTimestamp{i}", False)
61-
timestamp = self._parse_timestamp(kwargs.get(f"timestamp{i}", "0"))
64+
timestamp = self._parse_timestamp(kwargs.get(f"timestamp{i}", 0.0))
6265

6366
frameImages.append(
6467
self._createFrameEntry(
@@ -83,7 +86,10 @@ def _parse_timestamp(value, default=0.0):
8386
stripped = value.strip()
8487
if stripped == "":
8588
return default
86-
return max(0.0, float(stripped))
89+
try:
90+
return max(0.0, float(stripped))
91+
except ValueError:
92+
return default
8793
return default
8894

8995
def _createFrameEntry(self, image, use_frame, frame_position, use_timestamp, timestamp):

0 commit comments

Comments
 (0)