main
py 37 lines 1.07 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 from typing import Literal, NamedTuple
5
6 from vllm import envs
7
8 PYNVVIDEOCODEC_VIDEO_BACKEND: Literal["pynvvideocodec"] = "pynvvideocodec"
9 PYNVVIDEOCODEC_DEFAULT_HW_DECODERS = 2
10
11
12 class VideoTargetMetadata(NamedTuple):
13 """Metadata describing the requested video sample."""
14
15 num_frames: int
16 fps: float
17 max_duration: float
18
19
20 class VideoSourceMetadata(NamedTuple):
21 """Metadata describing the encoded video source."""
22
23 total_frames_num: int
24 original_fps: float
25 duration: float
26
27
28 def check_frame_pixel_limit(width: int, height: int) -> None:
29 """Reject video frames exceeding ``VLLM_MAX_IMAGE_PIXELS``."""
30 max_pixels = envs.VLLM_MAX_IMAGE_PIXELS
31 if max_pixels > 0 and width * height > max_pixels:
32 raise ValueError(
33 f"Video frame dimensions {width}x{height} "
34 f"({width * height} pixels) exceed the maximum of "
35 f"{max_pixels} pixels. Set VLLM_MAX_IMAGE_PIXELS to "
36 f"increase this limit."
37 )