The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix nondeterministic video decode at unaligned widths (CORE-299) (#14438)
John Pollocka1d95f3f8266
diff --git a/comfy_api/latest/_input_impl/video_types.py b/comfy_api/latest/_input_impl/video_types.pyindex dfdf58515..92a1298c0 100644--- a/comfy_api/latest/_input_impl/video_types.py+++ b/comfy_api/latest/_input_impl/video_types.py@@ -270,6 +270,7 @@ class VideoFromFile(VideoInput):image_format = 'gbrpf32le'process_image_format = lambda a: a+ align_graph = Noneaudio = Nonestreams = [video_stream]@@ -323,7 +324,24 @@ class VideoFromFile(VideoInput):checked_alpha = True- img = frame.to_ndarray(format=image_format) # shape: (H, W, 4)+ # Fix non-deterministic video decode when the video width is not a multiple of 32+ # For non-yuvj pixel formats (all H.264/H.265 video)+ if image_format in ('gbrpf32le', 'gbrapf32le') and frame.width % 32 != 0:+ if align_graph is None:+ pad_w = ((frame.width + 31) // 32) * 32+ g = av.filter.Graph()+ g_src = g.add_buffer(width=frame.width, height=frame.height,+ format=frame.format.name, time_base=video_stream.time_base)+ g_pad = g.add('pad', f'{pad_w}:{frame.height}:0:0')+ g_sink = g.add('buffersink')+ g_src.link_to(g_pad)+ g_pad.link_to(g_sink)+ g.configure()+ align_graph = (g, g_src, g_sink)+ align_graph[1].push(frame)+ img = np.ascontiguousarray(align_graph[2].pull().to_ndarray(format=image_format)[:, :frame.width])+ else:+ img = frame.to_ndarray(format=image_format)if frame.rotation != 0:k = int(round(frame.rotation // 90))img = np.rot90(img, k=k, axes=(0, 1)).copy()