From ae7bf483312afcd0ed1603f006fecb04ea6581e1 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Wed, 28 Jan 2026 23:15:06 -0800 Subject: [PATCH] Count packets unless codec has subframes --- comfy_api/latest/_input_impl/video_types.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/comfy_api/latest/_input_impl/video_types.py b/comfy_api/latest/_input_impl/video_types.py index c796d82ee..befe438bb 100644 --- a/comfy_api/latest/_input_impl/video_types.py +++ b/comfy_api/latest/_input_impl/video_types.py @@ -120,7 +120,12 @@ class VideoFromFile(VideoInput): if video_stream and video_stream.average_rate: frame_count = 0 container.seek(0) - for packet in container.demux(video_stream): + frame_iterator = ( + container.decode(video_stream) + if video_stream.codec.capabilities & 0x100 + else container.demux(video_stream) + ) + for packet in frame_iterator: for _ in packet.decode(): frame_count += 1 if frame_count > 0: @@ -165,7 +170,11 @@ class VideoFromFile(VideoInput): frame_count = 1 start_pts = int(self.__start_time / video_stream.time_base) container.seek(start_pts, stream=video_stream) - frame_iterator = container.decode(video_stream) + frame_iterator = ( + container.decode(video_stream) + if video_stream.codec.capabilities & 0x100 + else container.demux(video_stream) + ) for frame in frame_iterator: if frame.pts >= start_pts: break