microsoft/autogen · error · ValueError
video_path must be a local file path, not a URL.
Error message
video_path must be a local file path, not a URL.
What it means
The extract_audio tool in autogen_ext.agents.video_surfer invokes ffmpeg on a caller-supplied video_path. As an SSRF guard it rejects any path matching a URL scheme (scheme://...) with a ValueError — video must be a local file. Only http(s), file, ftp, etc. are local to the process via ffmpeg protocol handlers, which could be abused to reach internal hosts.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/agents/video_surfer/tools.py:28
ChatCompletionClient,
UserMessage,
)
def extract_audio(video_path: str, audio_output_path: str) -> str:
"""
Extracts audio from a video file and saves it as an MP3 file.
:param video_path: Path to the video file (must be a local file path, not a URL).
:param audio_output_path: Path to save the extracted audio file (must end with .mp3).
:return: Confirmation message with the path to the saved audio file.
"""
import os
import re
# Reject URLs to prevent SSRF via ffmpeg
if re.match(r"^[a-zA-Z][a-zA-Z0-9+\-.]*://", video_path):
raise ValueError("video_path must be a local file path, not a URL.")
# Enforce .mp3 extension to prevent writing arbitrary file types
if not audio_output_path.lower().endswith(".mp3"):
raise ValueError("audio_output_path must end with .mp3.")
# Prevent path traversal — output must stay within the current working directory
cwd = os.path.realpath(os.getcwd())
output_real = os.path.realpath(audio_output_path)
if not output_real.startswith(cwd + os.sep) and output_real != cwd:
raise ValueError("audio_output_path must be within the current working directory.")
(ffmpeg.input(video_path).output(audio_output_path, format="mp3").run(quiet=True, overwrite_output=True)) # type: ignore
return f"Audio extracted and saved to {audio_output_path}."
def transcribe_audio_with_timestamps(audio_path: str) -> str:
"""
Transcribes the audio file with timestamps using the Whisper model.View on GitHub (pinned to 027ecf0a37)
Solutions
- Download the video to a local file first (e.g. httpx/requests), then pass the local path to extract_audio.
- Validate/sanitize model-provided arguments before tool execution so URLs never reach the tool.
- In agent instructions, state that video_path must be a local file path.
Example fix
# before
extract_audio("https://cdn.example.com/clip.mp4", "/tmp/out/clip.mp3")
# after
import httpx
video_local = "/tmp/work/clip.mp4"
with httpx.Client(follow_redirects=True) as http, open(video_local, "wb") as f:
f.write(http.get("https://cdn.example.com/clip.mp4").content)
extract_audio(video_local, "/tmp/work/clip.mp3") Defensive patterns
Strategy: validation
Validate before calling
import re, os
def is_local_video_path(path: str) -> bool:
return not re.match(r"^[a-zA-Z][a-zA-Z0-9+\-.]*://", path) and os.path.exists(path) Type guard
import re
def is_local_path(p: str) -> bool:
return isinstance(p, str) and not re.match(r"^[a-zA-Z][a-zA-Z0-9+\-.]*://", p) Prevention
- Download remote media to a local file before calling extract_audio.
- Sanitize LLM-provided tool arguments; reject scheme-prefixed paths.
- Tell the model in the prompt that video_path must be local.
When it happens
Trigger: Calling extract_audio(video_path="https://example.com/clip.mp4", ...) or any string with an <alpha><alnum+.->:// prefix (file://, ftp://, smb://, ...).
Common situations: LLM-driven VideoSurfer agents passing a scraped URL straight into the tool; user input containing a URL where a downloaded local path was expected.
Related errors
- audio_output_path must end with .mp3.
- audio_output_path must be within the current working directo
- Working directory (cwd) '{cwd}' is not valid. It must be wit
- Cannot open video file {video_path}
- Failed to capture frame at {timestamp:.2f}s
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/dc095ebc6b7527b1.
Report an issue: GitHub.