run-llama/llama_index · error · ValueError
resolve_video returned zero bytes
Error message
resolve_video returned zero bytes
What it means
Raised by VideoBlock.resolve_video when the buffer resolved from raw bytes, path, or URL is empty (zero bytes). It is the video equivalent of the image/audio zero-byte guards and stops empty video payloads before an API call.
Source
Thrown at llama-index-core/llama_index/core/base/llms/types.py:635
"""
data_buffer = (
self.video
if isinstance(self.video, IOBase)
else resolve_binary(
raw_bytes=self.video,
path=self.path,
url=str(self.url) if self.url else None,
as_base64=as_base64,
)
)
# Check size by seeking to end and getting position
data_buffer.seek(0, 2) # Seek to end
size = data_buffer.tell()
data_buffer.seek(0) # Reset to beginning
if size == 0:
raise ValueError("resolve_video returned zero bytes")
return data_buffer
def inline_url(self) -> str:
b64 = self.resolve_video(as_base64=True)
b64_str = b64.read().decode("utf-8")
if self.video_mimetype:
return f"data:{self.video_mimetype};base64,{b64_str}"
return f"data:video;base64,{b64_str}"
async def aestimate_tokens(self, *args: Any, **kwargs: Any) -> int:
"""
Use TinyTag to estimate the duration of the video file and convert to tokens.
Gemini estimates 263 tokens per second of video
https://ai.google.dev/gemini-api/docs/tokens?lang=python
"""
try:
# First try tinytagView on GitHub (pinned to afd0fef371)
Solutions
- Check size before building the block: os.path.getsize(path) > 0 / len(raw) > 0.
- For URL sources, download once, verify non-empty, then pass raw bytes or a verified path.
- Fix the upstream producer/downloader responsible for empty artifacts.
Example fix
# before
block = VideoBlock(path="intro.mp4") # 0-byte file
buf = block.resolve_video(as_base64=True)
# after
if os.path.getsize("intro.mp4") == 0:
raise RuntimeError("empty video file")
block = VideoBlock(path="intro.mp4")
buf = block.resolve_video(as_base64=True) Defensive patterns
Strategy: validation
Validate before calling
import os
ok = (video_bytes and len(video_bytes) > 0) or (path and os.path.getsize(path) > 0)
if not ok:
raise ValueError("video source is empty") Try / catch
try:
buf = block.resolve_video(as_base64=True)
except ValueError as e:
if "zero bytes" in str(e):
refetch_or_skip()
else:
raise Prevention
- Validate video artifacts right after download/creation.
- Log and quarantine 0-byte media files upstream.
When it happens
Trigger: VideoBlock(video=b"" or data=b""), a 0-byte video file, or a video URL that returns an empty response.
Common situations: Video ingestion where a downloader wrote an empty file; interrupted uploads; placeholder/fixture video records; expired signed URLs.
Related errors
- resolve_image returned zero bytes
- resolve_audio returned zero bytes
- resolve_document returned zero bytes
- LLM must be a FunctionCallingLLM
- No embeddings to aggregate
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/0014cc1f9a113bd1.
Report an issue: GitHub.