mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-14 20:09:24 +08:00
Fix nondeterministic video decode at unaligned widths (CORE-299) (#14438)
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
This commit is contained in:
parent
64cc078069
commit
a1d95f3f82
@ -270,6 +270,7 @@ class VideoFromFile(VideoInput):
|
|||||||
|
|
||||||
image_format = 'gbrpf32le'
|
image_format = 'gbrpf32le'
|
||||||
process_image_format = lambda a: a
|
process_image_format = lambda a: a
|
||||||
|
align_graph = None
|
||||||
audio = None
|
audio = None
|
||||||
|
|
||||||
streams = [video_stream]
|
streams = [video_stream]
|
||||||
@ -323,7 +324,24 @@ class VideoFromFile(VideoInput):
|
|||||||
|
|
||||||
checked_alpha = True
|
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:
|
if frame.rotation != 0:
|
||||||
k = int(round(frame.rotation // 90))
|
k = int(round(frame.rotation // 90))
|
||||||
img = np.rot90(img, k=k, axes=(0, 1)).copy()
|
img = np.rot90(img, k=k, axes=(0, 1)).copy()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user