examples.test_video¶
Test script for VLM video support in vllm-mlx.
View the complete module source at #L1-L349.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
examples.test_video
¶
Test script for VLM video support in vllm-mlx.
This script tests video understanding capabilities by: 1. Downloading a sample video (or using a local one) 2. Loading a VLM model that supports video 3. Running inference on the video
Usage
python examples/test_video.py python examples/test_video.py --video /path/to/video.mp4 python examples/test_video.py --model mlx-community/Qwen3-VL-8B-Instruct-4bit
examples.test_video.download_sample_video
¶
Download a sample video for testing.
Source code in examples/test_video.py
examples.test_video.create_test_video
¶
Create a simple test video using OpenCV if download fails.
Source code in examples/test_video.py
examples.test_video.get_video_info
¶
Get information about a video file.
Source code in examples/test_video.py
examples.test_video.test_frame_extraction
¶
Test video frame extraction.
Source code in examples/test_video.py
examples.test_video.test_video_generation
¶
Test video understanding with VLM.
Source code in examples/test_video.py
examples.test_video.test_video_url
¶
Test video from URL.
Source code in examples/test_video.py
examples.test_video.main
¶
Source code in examples/test_video.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
examples.test_video.download_sample_video · function
Download a sample video for testing.
Parameters
This callable has no explicit inputs.
Returns
- Type:
str - Direct return expressions:
temp_file.name
Exceptions and behavior
Function download_sample_video calls logger.info, requests.get, response.raise_for_status, tempfile.NamedTemporaryFile; returns temp_file.name.
No direct raise statement appears in this definition.
examples.test_video.create_test_video · function
Create a simple test video using OpenCV if download fails.
Parameters
This callable has no explicit inputs.
Returns
- Type:
str - Direct return expressions:
temp_file.name
Exceptions and behavior
Function create_test_video calls logger.error, sys.exit, logger.info, tempfile.NamedTemporaryFile; returns temp_file.name.
No direct raise statement appears in this definition.
examples.test_video.get_video_info · function
Get information about a video file.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
video_path |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
dict - Direct return expressions:
{'error': 'Cannot open video'};info
Exceptions and behavior
Function get_video_info calls cv2.VideoCapture, cap.isOpened, int, cap.get; has 2 explicit return paths.
No direct raise statement appears in this definition.
examples.test_video.test_frame_extraction · function
Test video frame extraction.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
video_path |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated
Exceptions and behavior
Function test_frame_extraction calls logger.info, get_video_info, time.time, extract_video_frames_smart.
No direct raise statement appears in this definition.
examples.test_video.test_video_generation · function
Test video understanding with VLM.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
video_path |
str |
yes |
none |
Required positional or keyword input. |
model_name |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
model
Exceptions and behavior
Function test_video_generation calls logger.info, time.time, MLXVisionLanguageModel, model.load; returns model.
No direct raise statement appears in this definition.
examples.test_video.test_video_url · function
Test video from URL.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
model |
not annotated |
yes |
none |
Required positional or keyword input. |
video_url |
str |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
not annotated - Direct return expressions:
True
Exceptions and behavior
Function test_video_url calls logger.info, time.time, model.chat, model.generate; returns True.
No direct raise statement appears in this definition.
examples.test_video.main · function
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, Path(video_path).exists.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, Path(video_path).exists.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
download_sample_video |
function | download_sample_video() -> str |
Download a sample video for testing. | #L27-L56 |
create_test_video |
function | create_test_video() -> str |
Create a simple test video using OpenCV if download fails. | #L59-L105 |
get_video_info |
function | get_video_info(video_path: str) -> dict |
Get information about a video file. | #L108-L126 |
test_frame_extraction |
function | test_frame_extraction(video_path: str) -> not annotated |
Test video frame extraction. | #L129-L145 |
test_video_generation |
function | test_video_generation(video_path: str, model_name: str) -> not annotated |
Test video understanding with VLM. | #L148-L219 |
test_video_url |
function | test_video_url(model, video_url: str) -> not annotated |
Test video from URL. | #L222-L266 |
main |
function | main() -> not annotated |
Function main calls argparse.ArgumentParser, parser.add_argument, parser.parse_args, Path(video_path).exists. |
#L269-L345 |