{"record":{"id":"a00b1d8b7c93ff3a","repo":"langchain-ai/deepagents","slug":"video-frame-dimensions-width-x-height-exceed-the","errorCode":null,"errorMessage":"Video frame dimensions {width}x{height} exceed the maximum {MAX_VIDEO_FRAME_SIDE}px side","messagePattern":"Video frame dimensions (.+?)x(.+?) exceed the maximum (.+?)px side","errorType":"exception","errorClass":"VideoExtractionError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/_video.py","lineNumber":291,"sourceCode":"    return None\n\n\ndef _frame_dimensions(frame: Any) -> tuple[int, int] | None:  # noqa: ANN401  # PyAV types are unavailable without the [video] extra\n    \"\"\"Return frame dimensions when the decoder exposes them.\"\"\"\n    width = getattr(frame, \"width\", None)\n    height = getattr(frame, \"height\", None)\n    if width is None or height is None:\n        return None\n    return int(width), int(height)\n\n\ndef _validate_dimensions(width: int, height: int) -> None:\n    \"\"\"Reject frame dimensions that are too large to safely convert.\"\"\"\n    if width <= 0 or height <= 0:\n        return\n    if width > MAX_VIDEO_FRAME_SIDE or height > MAX_VIDEO_FRAME_SIDE:\n        msg = f\"Video frame dimensions {width}x{height} exceed the maximum {MAX_VIDEO_FRAME_SIDE}px side\"\n        raise VideoExtractionError(msg)\n\n\ndef _check_decode_deadline(deadline_seconds: float | None) -> None:\n    \"\"\"Raise when best-effort video decoding has exceeded its time budget.\"\"\"\n    if deadline_seconds is not None and time.monotonic() > deadline_seconds:\n        msg = f\"Video decoding exceeded the {MAX_VIDEO_DECODE_SECONDS:.1f}s safety budget\"\n        raise VideoExtractionError(msg)\n\n\ndef _sample_frames_in_window(\n    decoded_frames: Any,  # noqa: ANN401  # PyAV types are unavailable without the [video] extra\n    *,\n    offset_seconds: float,\n    duration_seconds: float,\n    sampling_rate: float,\n    time_base: float,\n    stream_start_seconds: float = 0.0,\n    deadline_seconds: float | None = None,","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/_video.py#L273-L309","documentation":"`_validate_dimensions`, invoked during JPEG encoding, rejects any frame whose width or height exceeds `MAX_VIDEO_FRAME_SIDE`. Guarding before conversion prevents allocating enormous images (memory exhaustion / decompression bombs) from hostile or 8K+ sources.","triggerScenarios":"Extracting frames from very high-resolution video (e.g. 8K, or crafted small files with huge frame dimensions) so a decoded frame's side exceeds the max allowed px.","commonSituations":"User-uploaded 7680x4320 footage; adversarial inputs designed to blow up memory; unexpected orientation metadata producing oversized frames.","solutions":["Pre-scale/downsample the source video before extraction (ffmpeg -vf scale=...)","Catch `VideoExtractionError` and reject oversized inputs with a clear user message","Check the source resolution ahead of time and skip videos exceeding the limit"],"exampleFix":"// before\nframes = extract_video_frames(huge_8k_bytes, offset_seconds=0, duration_seconds=10, sampling_rate=1)\n// after\nsub = subprocess.run([\"ffmpeg\", \"-i\", \"in.mp4\", \"-vf\", \"scale=3840:-2\", \"out.mp4\"])\nframes = extract_video_frames(scaled_bytes, offset_seconds=0, duration_seconds=10, sampling_rate=1)","handlingStrategy":"validation","validationCode":"import av\nwith av.open(io.BytesIO(content)) as c:\n    stream = next(s for s in c.streams if s.type == \"video\")\n    w, h = stream.codec_context.width, stream.codec_context.height\n    if w > MAX_VIDEO_FRAME_SIDE or h > MAX_VIDEO_FRAME_SIDE:\n        raise ValueError(f\"source resolution {w}x{h} too large\")","typeGuard":"def dimensions_ok(width: int, height: int, max_side: int = MAX_VIDEO_FRAME_SIDE) -> bool:\n    return 0 < width <= max_side and 0 < height <= max_side","tryCatchPattern":"try:\n    result = extract_video_frames(content, offset_seconds=0, duration_seconds=10, sampling_rate=1)\nexcept VideoExtractionError as exc:\n    if \"exceed the maximum\" in str(exc):\n        content = downscale_video(content)\n        result = extract_video_frames(content, offset_seconds=0, duration_seconds=10, sampling_rate=1)","preventionTips":["Pre-scale 4K/8K sources before extraction","Check stream dimensions with ffprobe on ingest","Reject oversized uploads at the API boundary"],"tags":["video","image-size","resource-limit","security"],"backgroundTag":"frame-dimensions-exceed-limit","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}