{"record":{"id":"93a5225fa470a4da","repo":"langchain-ai/deepagents","slug":"video-decoding-exceeded-the-max-video-decode-seco","errorCode":null,"errorMessage":"Video decoding exceeded the {MAX_VIDEO_DECODE_SECONDS:.1f}s safety budget","messagePattern":"Video decoding exceeded the (.+?)s safety budget","errorType":"exception","errorClass":"VideoExtractionError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/_video.py","lineNumber":298,"sourceCode":"    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,\n    decode_error_types: tuple[type[BaseException], ...] = (),\n) -> list[ContentBlock]:\n    \"\"\"Pick JPEG+timestamp content blocks for frames inside the requested window.\"\"\"\n    frame_interval_seconds = 1.0 / sampling_rate\n    end_seconds = offset_seconds + float(duration_seconds)\n    next_emit_seconds = offset_seconds\n    blocks: list[ContentBlock] = []","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/_video.py#L280-L316","documentation":"Video decoding is best-effort with a wall-clock budget of `MAX_VIDEO_DECODE_SECONDS`. `_check_decode_deadline` raises `VideoExtractionError` when `time.monotonic()` passes the deadline, protecting the agent from pathological inputs (huge files, slow codecs) that would hang extraction.","triggerScenarios":"Sampling a long or high-fps video whose decode loop exceeds the safety budget; very slow host CPU; deeply coded streams that decode few usable frames per second.","commonSituations":"Hour-long screen recordings sampled at high rates; containerized environments with throttled CPU; corrupt streams that make the decoder spin.","solutions":["Extract a shorter window (smaller `duration_seconds`) or lower `sampling_rate`","Pre-transcode/compress the video to a smaller resolution before extraction","Catch `VideoExtractionError` and fall back to metadata-only or thumbnail handling","Run extraction in a worker pool so the budget miss doesn't block the agent"],"exampleFix":"// before\nframes = extract_video_frames(two_hour_recording, offset_seconds=0, duration_seconds=7200, sampling_rate=2)\n// after\nframes = extract_video_frames(two_hour_recording, offset_seconds=start, duration_seconds=60, sampling_rate=0.5)","handlingStrategy":"validation","validationCode":"duration = get_video_duration(content)  # via ffprobe/PyAV\nif duration > MAX_REASONABLE_DURATION:\n    raise ValueError(\"video too long for inline extraction\")","typeGuard":null,"tryCatchPattern":"try:\n    result = extract_video_frames(content, offset_seconds=0, duration_seconds=window, sampling_rate=1)\nexcept VideoExtractionError as exc:\n    if \"safety budget\" in str(exc):\n        result = extract_video_frames(content, offset_seconds=0, duration_seconds=window / 4, sampling_rate=0.5)","preventionTips":["Keep duration/sampling_rate modest for long recordings","Extract in chunks instead of one huge window","Run extraction off the main agent loop with a timeout"],"tags":["video","timeout","resource-limit","performance"],"backgroundTag":"processing-timeout","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}