vllm - ✅(Solved) Fix [Bug]: vLLM serving cannot support video inputs with a list of base64-encoded extracted JPEG frames [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#37274Fetched 2026-04-08 00:48:22
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
closed ×1commented ×1cross-referenced ×1labeled ×1

Error Message

import base64 import json import os import tempfile import cv2 import requests

MODEL_NAME="Qwen/Qwen3.5-2B" REQUEST_URL= "http://localhost:41091/v1/chat/completions" video_url='https://videos.pexels.com/video-files/5992517/5992517-hd_1920_1080_30fps.mp4'

print(f"Downloading video from {video_url}...")

1. Download video

response = requests.get(video_url, stream=True) if response.status_code == 200: temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") for chunk in response.iter_content(chunk_size=8192): temp_file.write(chunk) temp_file.close() video_path = temp_file.name else: print("Failed to download video") exit(1)

print("Extracting frames...")

2. Extract frames, resize, base64 encode

cap = cv2.VideoCapture(video_path) if not cap.isOpened(): print("Error opening video file") exit(1)

fps = max(1, int(cap.get(cv2.CAP_PROP_FPS))) video_base64_frames = [] frame_count = 0

while True: ret, frame = cap.read() if not ret: break

# fps=1
if frame_count % fps == 0:
    resized_frame = cv2.resize(frame, (480, 270))
    
    # Encode to JPEG
    _, buffer = cv2.imencode('.jpg', resized_frame)
    
    # Base64 encode
    b64_str = base64.b64encode(buffer).decode('utf-8')
    video_base64_frames.append(b64_str)
    
frame_count += 1

cap.release() os.remove(video_path) print(f"Extracted {len(video_base64_frames)} frames.")

3. Request

print("Sending request to server...") headers = {"Content-Type": "application/json"} data = { "model": MODEL_NAME, "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe the video content in detail." }, { "type": "video_url", "video_url": {"url": f"data:video/jpeg;base64,{','.join(video_base64_frames)}"}, "fps": 1 } ] } ], "max_tokens": 128 }

resp = requests.post(REQUEST_URL, headers=headers, json=data) print("Response details:") print(f"Status Code: {resp.status_code}") try: print(json.dumps(resp.json(), indent=2)) except json.JSONDecodeError: print(resp.text)

Root Cause

The may caused by this implementation: video.py#L74

Fix Action

Fix / Workaround

============================== CPU Info

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 112 On-line CPU(s) list: 0-111 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) Gold 6348 CPU @ 2.60GHz CPU family: 6 Model: 106 Thread(s) per core: 2 Core(s) per socket: 28 Socket(s): 2 Stepping: 6 CPU(s) scaling MHz: 32% CPU max MHz: 3500.0000 CPU min MHz: 800.0000 BogoMIPS: 5200.00 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 2.6 MiB (56 instances) L1i cache: 1.8 MiB (56 instances) L2 cache: 70 MiB (56 instances) L3 cache: 84 MiB (2 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0-27,56-83 NUMA node1 CPU(s): 28-55,84-111 Vulnerability Gather data sampling: Mitigation; Microcode Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected

The workaround in my environment could be:

def load_base64(
    self, media_type: str, data: str
) -> tuple[npt.NDArray, dict[str, Any]]:
    if media_type.lower() == "video/jpeg":
        load_frame = partial(
            self.image_io.load_base64,
            "image/jpeg",
        )

# 
        # workaround:
        # 
        frames = np.stack([np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]) 
        total = int(frames.shape[0]) 
        fps = float(self.kwargs.get("fps", 1)) 
        duration = (total / fps) if fps > 0 else 0.0 
        metadata = { 
            "total_num_frames": total, 
            "fps": fps, 
            "duration": duration, 
            "video_backend": "jpeg_sequence", 
            "frames_indices": list(range(total)), 
            "do_sample_frames": False, 
        }

PR fix notes

PR #37301: [Bugfix] Fix base64 JPEG video frames returning empty metadata

Description (problem / solution / changelog)

Problem

Sending base64-encoded JPEG frames as video input returns a 400 error:

VideoMetadata.__init__() missing 1 required positional argument: 'total_num_frames'

VideoMediaIO.load_base64 handles the video/jpeg media type by decoding individual JPEG frames and stacking them, but returns an empty metadata dict {}. Downstream code passes this to transformers.video_utils.VideoMetadata(**metadata) which requires total_num_frames as a positional argument.

Root Cause

In vllm/multimodal/media/video.py:83-85:

return np.stack(
    [np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]
), {}  # <-- empty metadata

All other video loading paths (via load_bytesvideo_loader.load_bytes) return properly populated metadata through create_hf_metadata(), but the base64 JPEG path was missed.

Fix

Populate the metadata dict with the same fields other loaders return:

  • total_num_frames: frame count from the stacked array
  • fps: from request kwargs (default 1)
  • duration: computed from total_num_frames / fps
  • video_backend: "jpeg_sequence" to distinguish from other backends
  • frames_indices: [0, 1, ..., N-1] since all frames are used directly
  • do_sample_frames: False since frames are pre-extracted by the client

Test plan

  • Verify base64 JPEG frame video input no longer returns 400
  • Ensure metadata fields match what VideoMetadata expects

Fixes #37274

Changed files

  • tests/multimodal/media/test_video.py (modified, +52/-0)
  • vllm/multimodal/media/video.py (modified, +14/-2)

Code Example

Collecting environment information...
==============================
        System Info
==============================
OS                           : Ubuntu 24.04.4 LTS (x86_64)
GCC version                  : (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version                : Could not collect
CMake version                : version 3.28.3
Libc version                 : glibc-2.39

==============================
       PyTorch Info
==============================
PyTorch version              : 2.10.0+cu128
Is debug build               : False
CUDA used to build PyTorch   : 12.8
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.11.0 (main, Jan 23 2026, 16:28:26) [GCC 9.5.0] (64-bit runtime)
Python platform              : Linux-6.8.0-94-generic-x86_64-with-glibc2.39

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : 12.4.99
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : 
GPU 0: NVIDIA A100 80GB PCIe
GPU 1: NVIDIA A100 80GB PCIe
GPU 2: NVIDIA A100 80GB PCIe

Nvidia driver version        : 550.163.01
cuDNN version                : Could not collect
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        46 bits physical, 57 bits virtual
Byte Order:                           Little Endian
CPU(s):                               112
On-line CPU(s) list:                  0-111
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) Gold 6348 CPU @ 2.60GHz
CPU family:                           6
Model:                                106
Thread(s) per core:                   2
Core(s) per socket:                   28
Socket(s):                            2
Stepping:                             6
CPU(s) scaling MHz:                   32%
CPU max MHz:                          3500.0000
CPU min MHz:                          800.0000
BogoMIPS:                             5200.00
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            2.6 MiB (56 instances)
L1i cache:                            1.8 MiB (56 instances)
L2 cache:                             70 MiB (56 instances)
L3 cache:                             84 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-27,56-83
NUMA node1 CPU(s):                    28-55,84-111
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Not affected

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.6.4
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.1
[pip3] nvidia-cutlass-dsl-libs-base==4.4.1
[pip3] nvidia-ml-py==13.590.48
[pip3] nvidia-nccl-cu12==2.27.5
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0
[pip3] torch_c_dlpack_ext==0.1.5
[pip3] torchaudio==2.10.0
[pip3] torchvision==0.25.0
[pip3] transformers==4.57.6
[pip3] triton==3.6.0
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.17.1
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
  	GPU0	GPU1	GPU2	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	PIX	PXB	0-27,56-83	0		N/A
GPU1	PIX	 X 	PXB	0-27,56-83	0		N/A
GPU2	PXB	PXB	 X 	0-27,56-83	0		N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

==============================
     Environment Variables
==============================
LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:/usr/local/cuda-12.4/lib64:
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_{username}

---

import base64
import json
import os
import tempfile
import cv2
import requests

MODEL_NAME="Qwen/Qwen3.5-2B"
REQUEST_URL= "http://localhost:41091/v1/chat/completions"
video_url='https://videos.pexels.com/video-files/5992517/5992517-hd_1920_1080_30fps.mp4'

print(f"Downloading video from {video_url}...")
# 1. Download video
response = requests.get(video_url, stream=True)
if response.status_code == 200:
    temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
    for chunk in response.iter_content(chunk_size=8192):
        temp_file.write(chunk)
    temp_file.close()
    video_path = temp_file.name
else:
    print("Failed to download video")
    exit(1)

print("Extracting frames...")
# 2. Extract frames, resize, base64 encode
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
    print("Error opening video file")
    exit(1)

fps = max(1, int(cap.get(cv2.CAP_PROP_FPS)))
video_base64_frames = []
frame_count = 0

while True:
    ret, frame = cap.read()
    if not ret:
        break
    
    # fps=1
    if frame_count % fps == 0:
        resized_frame = cv2.resize(frame, (480, 270))
        
        # Encode to JPEG
        _, buffer = cv2.imencode('.jpg', resized_frame)
        
        # Base64 encode
        b64_str = base64.b64encode(buffer).decode('utf-8')
        video_base64_frames.append(b64_str)
        
    frame_count += 1

cap.release()
os.remove(video_path)
print(f"Extracted {len(video_base64_frames)} frames.")

# 3. Request
print("Sending request to server...")
headers = {"Content-Type": "application/json"}
data = {
    "model": MODEL_NAME,
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Describe the video content in detail."
                },
                {
                    "type": "video_url",
                    "video_url": {"url": f"data:video/jpeg;base64,{','.join(video_base64_frames)}"},
                    "fps": 1
                }
            ]
        }
    ],
    "max_tokens": 128
}

resp = requests.post(REQUEST_URL, headers=headers, json=data)
print("Response details:")
print(f"Status Code: {resp.status_code}")
try:
    print(json.dumps(resp.json(), indent=2))
except json.JSONDecodeError:
    print(resp.text)

---

Extracting frames...
Extracted 58 frames.
Sending request to server...
Response details:
Status Code: 400
{
  "error": {
    "message": "VideoMetadata.__init__() missing 1 required positional argument: 'total_num_frames'",
    "type": "BadRequestError",
    "param": null,
    "code": 400
  }
}

---

def load_base64(
    self, media_type: str, data: str
) -> tuple[npt.NDArray, dict[str, Any]]:
    if media_type.lower() == "video/jpeg":
        load_frame = partial(
            self.image_io.load_base64,
            "image/jpeg",
        )

        # return np.stack(
        #     [np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]
        # ), {}
        
        # 
        # workaround:
        # 
        frames = np.stack([np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]) 
        total = int(frames.shape[0]) 
        fps = float(self.kwargs.get("fps", 1)) 
        duration = (total / fps) if fps > 0 else 0.0 
        metadata = { 
            "total_num_frames": total, 
            "fps": fps, 
            "duration": duration, 
            "video_backend": "jpeg_sequence", 
            "frames_indices": list(range(total)), 
            "do_sample_frames": False, 
        } 

        return frames, metadata 

    return self.load_bytes(base64.b64decode(data))
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>The output of <code>python collect_env.py</code></summary>
Collecting environment information...
==============================
        System Info
==============================
OS                           : Ubuntu 24.04.4 LTS (x86_64)
GCC version                  : (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version                : Could not collect
CMake version                : version 3.28.3
Libc version                 : glibc-2.39

==============================
       PyTorch Info
==============================
PyTorch version              : 2.10.0+cu128
Is debug build               : False
CUDA used to build PyTorch   : 12.8
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.11.0 (main, Jan 23 2026, 16:28:26) [GCC 9.5.0] (64-bit runtime)
Python platform              : Linux-6.8.0-94-generic-x86_64-with-glibc2.39

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : 12.4.99
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : 
GPU 0: NVIDIA A100 80GB PCIe
GPU 1: NVIDIA A100 80GB PCIe
GPU 2: NVIDIA A100 80GB PCIe

Nvidia driver version        : 550.163.01
cuDNN version                : Could not collect
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        46 bits physical, 57 bits virtual
Byte Order:                           Little Endian
CPU(s):                               112
On-line CPU(s) list:                  0-111
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) Gold 6348 CPU @ 2.60GHz
CPU family:                           6
Model:                                106
Thread(s) per core:                   2
Core(s) per socket:                   28
Socket(s):                            2
Stepping:                             6
CPU(s) scaling MHz:                   32%
CPU max MHz:                          3500.0000
CPU min MHz:                          800.0000
BogoMIPS:                             5200.00
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            2.6 MiB (56 instances)
L1i cache:                            1.8 MiB (56 instances)
L2 cache:                             70 MiB (56 instances)
L3 cache:                             84 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-27,56-83
NUMA node1 CPU(s):                    28-55,84-111
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Not affected

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.6.4
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.1
[pip3] nvidia-cutlass-dsl-libs-base==4.4.1
[pip3] nvidia-ml-py==13.590.48
[pip3] nvidia-nccl-cu12==2.27.5
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pyzmq==27.1.0
[pip3] torch==2.10.0
[pip3] torch_c_dlpack_ext==0.1.5
[pip3] torchaudio==2.10.0
[pip3] torchvision==0.25.0
[pip3] transformers==4.57.6
[pip3] triton==3.6.0
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.17.1
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled
GPU Topology:
  	GPU0	GPU1	GPU2	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	PIX	PXB	0-27,56-83	0		N/A
GPU1	PIX	 X 	PXB	0-27,56-83	0		N/A
GPU2	PXB	PXB	 X 	0-27,56-83	0		N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

==============================
     Environment Variables
==============================
LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:/usr/local/cuda-12.4/lib64:
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_{username}
</details>

🐛 Describe the bug

The vLLM serving cannot support video inputs with a list of base64-encoded extracted JPEG frames. This usage is needed, since in my case the input video could be rather long and the resolusion might be large, I'd like to resize and sparsely sample frames before sending the request to vllm server.

A simple example:

import base64
import json
import os
import tempfile
import cv2
import requests

MODEL_NAME="Qwen/Qwen3.5-2B"
REQUEST_URL= "http://localhost:41091/v1/chat/completions"
video_url='https://videos.pexels.com/video-files/5992517/5992517-hd_1920_1080_30fps.mp4'

print(f"Downloading video from {video_url}...")
# 1. Download video
response = requests.get(video_url, stream=True)
if response.status_code == 200:
    temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
    for chunk in response.iter_content(chunk_size=8192):
        temp_file.write(chunk)
    temp_file.close()
    video_path = temp_file.name
else:
    print("Failed to download video")
    exit(1)

print("Extracting frames...")
# 2. Extract frames, resize, base64 encode
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
    print("Error opening video file")
    exit(1)

fps = max(1, int(cap.get(cv2.CAP_PROP_FPS)))
video_base64_frames = []
frame_count = 0

while True:
    ret, frame = cap.read()
    if not ret:
        break
    
    # fps=1
    if frame_count % fps == 0:
        resized_frame = cv2.resize(frame, (480, 270))
        
        # Encode to JPEG
        _, buffer = cv2.imencode('.jpg', resized_frame)
        
        # Base64 encode
        b64_str = base64.b64encode(buffer).decode('utf-8')
        video_base64_frames.append(b64_str)
        
    frame_count += 1

cap.release()
os.remove(video_path)
print(f"Extracted {len(video_base64_frames)} frames.")

# 3. Request
print("Sending request to server...")
headers = {"Content-Type": "application/json"}
data = {
    "model": MODEL_NAME,
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Describe the video content in detail."
                },
                {
                    "type": "video_url",
                    "video_url": {"url": f"data:video/jpeg;base64,{','.join(video_base64_frames)}"},
                    "fps": 1
                }
            ]
        }
    ],
    "max_tokens": 128
}

resp = requests.post(REQUEST_URL, headers=headers, json=data)
print("Response details:")
print(f"Status Code: {resp.status_code}")
try:
    print(json.dumps(resp.json(), indent=2))
except json.JSONDecodeError:
    print(resp.text)

Output:

Extracting frames...
Extracted 58 frames.
Sending request to server...
Response details:
Status Code: 400
{
  "error": {
    "message": "VideoMetadata.__init__() missing 1 required positional argument: 'total_num_frames'",
    "type": "BadRequestError",
    "param": null,
    "code": 400
  }
}

The may caused by this implementation: video.py#L74

The workaround in my environment could be:

def load_base64(
    self, media_type: str, data: str
) -> tuple[npt.NDArray, dict[str, Any]]:
    if media_type.lower() == "video/jpeg":
        load_frame = partial(
            self.image_io.load_base64,
            "image/jpeg",
        )

        # return np.stack(
        #     [np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]
        # ), {}
        
        # 
        # workaround:
        # 
        frames = np.stack([np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]) 
        total = int(frames.shape[0]) 
        fps = float(self.kwargs.get("fps", 1)) 
        duration = (total / fps) if fps > 0 else 0.0 
        metadata = { 
            "total_num_frames": total, 
            "fps": fps, 
            "duration": duration, 
            "video_backend": "jpeg_sequence", 
            "frames_indices": list(range(total)), 
            "do_sample_frames": False, 
        } 

        return frames, metadata 

    return self.load_bytes(base64.b64decode(data))

Do you have any suggestions on that case? Or if I may have missed something from the document about this use case...

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

Fix Plan

To fix the issue of the vLLM serving not supporting video inputs with a list of base64-encoded extracted JPEG frames, you can modify the load_base64 method in the video.py file.

Here are the steps:

  • Modify the load_base64 method to calculate the total number of frames, FPS, and duration.
  • Create a metadata dictionary with the required information.
  • Return the frames and metadata.

Example code:

def load_base64(
    self, media_type: str, data: str
) -> tuple[npt.NDArray, dict[str, Any]]:
    if media_type.lower() == "video/jpeg":
        load_frame = partial(
            self.image_io.load_base64,
            "image/jpeg",
        )

        frames = np.stack([np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]) 
        total = int(frames.shape[0]) 
        fps = float(self.kwargs.get("fps", 1)) 
        duration = (total / fps) if fps > 0 else 0.0 
        metadata = { 
            "total_num_frames": total, 
            "fps": fps, 
            "duration": duration, 
            "video_backend": "jpeg_sequence", 
            "frames_indices": list(range(total)), 
            "do_sample_frames": False, 
        } 

        return frames, metadata 

    return self.load_bytes(base64.b64decode(data))

Verification

To verify that the fix worked, you can test the modified load_base64 method with a sample video input.

  • Extract frames from a video file, resize, and base64 encode them.
  • Send a request to the vLLM server with the base64-encoded frames.
  • Check the response from the server to ensure that it can process the video input correctly.

Example test code:

# Extract frames, resize, and base64 encode
video_base64_frames = []
# ... (same code as before)

# Send request to server
headers = {"Content-Type": "application/json"}
data = {
    "model": MODEL_NAME,
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Describe the video content in detail."
                },
                {
                    "type": "video_url",
                    "video_url": {"url": f"data:video/jpeg;base64,{','.join(video_base64_frames)}"},
                    "fps": 1
                }
            ]
        }
    ],
    "max_tokens": 128
}

resp = requests.post(REQUEST_URL, headers=headers, json=data)
print("Response details:")
print(f"Status Code: {resp.status_code}")
try:
    print(json.dumps(resp.json(), indent=2))
except json.JSONDecodeError:
    print(resp.text)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

vllm - ✅(Solved) Fix [Bug]: vLLM serving cannot support video inputs with a list of base64-encoded extracted JPEG frames [1 pull requests, 1 comments, 2 participants]