ATH-MaaS/Pixelle-Video · error · ValueError

DashScope video input does not support data URLs in this ada

Error message

DashScope video input does not support data URLs in this adapter.

What it means

_to_dashscope_file_url raises ValueError when a video path is a data: URL, because the adapter only allows data URLs for images (allow_data_url=True) and DashScope video input here requires an accessible file/http URL. Videos cannot be inlined as base64 data URLs in this adapter.

Source

Thrown at pixelle_video/services/api_services/vlm_client.py:73

            print("-" * 30)

        if self.dashscope_client is None:
            raise RuntimeError("DashScope VLM API key is not configured.")

        image_urls = [self._to_dashscope_file_url(path, allow_data_url=True) for path in image_paths or []]
        video_urls = [self._to_dashscope_file_url(path, allow_data_url=False) for path in video_paths or []]
        return self.dashscope_client.chat(
            text=prompt,
            images=image_urls,
            videos=video_urls,
            model=selected_model,
            stream=False,
        )

    def _to_dashscope_file_url(self, path: str, allow_data_url: bool) -> str:
        if path.startswith("data:"):
            if not allow_data_url:
                raise ValueError("DashScope video input does not support data URLs in this adapter.")

            import base64 as b64
            import tempfile

            try:
                header, b64_data = path.split(",", 1)
                mime_type = header.split(";")[0].replace("data:", "")
                image_data = b64.b64decode(b64_data)
                suffix = f".{mime_type.split('/')[-1]}" if "/" in mime_type else ".png"
                with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as tmp:
                    tmp.write(image_data)
                    temp_path = tmp.name
                return f"file://{os.path.abspath(temp_path)}"
            except Exception as e:
                print(f"Error processing base64 image: {e}")
                raise ValueError(f"无法解析 base64 图片: {e}")

        if path.startswith("http") or path.startswith("file://"):

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Write the video bytes to a local file and pass the file path (the adapter converts it to file://...), or provide an http(s) URL
  2. Decode the data URL yourself: base64-decode the payload after the comma into a .mp4 temp file
  3. Adjust upstream producers to emit paths/URLs instead of data URLs for videos

Example fix

// before
query(prompt=p, video_paths=["data:video/mp4;base64,AAAA"])
// after
import base64, tempfile
b64 = "data:video/mp4;base64,AAAA".split(",",1)[1]
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as f:
    f.write(base64.b64decode(b64)); video_path = f.name
query(prompt=p, video_paths=[video_path])
Defensive patterns

Strategy: validation

Validate before calling

def validate_video_inputs(video_paths):
    for p in video_paths or []:
        if p.startswith("data:"):
            raise ValueError("Videos must be local file paths or http(s) URLs, not data URLs")

Type guard

def is_supported_video_input(p: str) -> bool:
    return p.startswith(("http://", "https://", "file://")) or (not p.startswith("data:") and __import__('os').path.isfile(p))

Try / catch

try:
    answer = vlm.query(prompt=p, video_paths=videos, model="qwen-vl-max")
except ValueError as e:
    if "data URLs" in str(e):
        videos = [materialize_to_file(v) for v in videos]  # decode data URLs to temp files
        answer = vlm.query(prompt=p, video_paths=videos, model="qwen-vl-max")
    else:
        raise

Prevention

When it happens

Trigger: Calling query(..., video_paths=["data:video/mp4;base64,..."]) — the call to _to_dashscope_file_url(path, allow_data_url=False) rejects it.

Common situations: Pipeline that encodes all media to base64 data URLs for images reuses the same encoding for videos; upstream frame-extractor emits data URLs; code that worked with an image-only API extended to videos unchanged.

Related errors


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/384ada960525730b. Report an issue: GitHub.