Comfy-Org/ComfyUI · error · RuntimeError
Failed to resize video: {str(e)}
Error message
Failed to resize video: {str(e)} What it means
Generic wrapper around any failure inside resize_video (PyAV). The except block closes containers and re-raises as RuntimeError('Failed to resize video: ...'). The inner text is the actual PyAV error — commonly a decode failure, unsupported pixel format, or the explicit 'resize produced no frames' ValueError from the same function.
Source
Thrown at comfy_api_nodes/util/conversions.py:557
break
# Carry odd audio time bases the mp4 muxer rejects; reset pts, encoder assigns clean ones (MP3-in-AVI)
audio_frame.pts = None
for packet in audio_stream.encode(audio_frame):
output_container.mux(packet)
for packet in audio_stream.encode():
output_container.mux(packet)
output_container.close()
input_container.close()
output_buffer.seek(0)
return InputImpl.VideoFromFile(output_buffer)
except Exception as e:
if input_container is not None:
input_container.close()
if output_container is not None:
output_container.close()
raise RuntimeError(f"Failed to resize video: {str(e)}") from e
def _f32_pcm(wav: torch.Tensor) -> torch.Tensor:
"""Convert audio to float 32 bits PCM format. Copy-paste from nodes_audio.py file."""
if wav.dtype.is_floating_point:
return wav
elif wav.dtype == torch.int16:
return wav.float() / (2**15)
elif wav.dtype == torch.int32:
return wav.float() / (2**31)
raise ValueError(f"Unsupported wav dtype: {wav.dtype}")
def audio_bytes_to_audio_input(audio_bytes: bytes) -> dict:
"""
Decode any common audio container from bytes using PyAV and return
a Comfy AUDIO dict: {"waveform": [1, C, T] float32, "sample_rate": int}.
"""View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Read the suffix after 'Failed to resize video:' to identify the root PyAV error.
- If it is 'resize produced no frames', fix start_time/duration (error 764).
- Ensure target dimensions are even (yuv420p constraint).
- Re-encode the source as standard H.264 MP4 and retry.
Defensive patterns
Strategy: try-catch
Validate before calling
out_w, out_h = target_dims
if out_w % 2 or out_h % 2:
raise ValueError('yuv420p requires even width and height') Try / catch
try:
out = resize_video(video, out_w, out_h, start_time, duration)
except RuntimeError as e:
if 'resize produced no frames' in str(e):
out = resize_video(video, out_w, out_h, 0.0, video.get_duration()) # full clip fallback
else:
raise Prevention
- Use even target dimensions for yuv420p encodes.
- Validate the decode-ability of the source with ffprobe first.
- Validate trim windows (see error 764) before resizing.
When it happens
Trigger: resize_video_to_max_pixels / resize_video on corrupted input, a container with no decodable video stream, an encoder rejecting the target dimensions (odd width/height with yuv420p), or the empty-selection ValueError from error 764.
Common situations: Feeding a broken download or a file with a mismatched extension; target resolution with odd dimensions (yuv420p requires even w/h); a very short clip combined with trimming parameters that select no frames.
Related errors
- Failed to trim video: {str(e)}
- No video stream found in file '{self.__file}'
- Could not determine duration for file '{self.__file}'
- No decodable video frames found in file '{self.__file}'
- Video too short: need at least 16 frames for Moonvalley
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/47838042c372f338.
Report an issue: GitHub.