Skip to content

vllm.multimodal.video_decoders.pynvvideocodec

Classes:

PyNvVideoCodecDecoderSlot

A retained PyNv decoder slot and its CUDA stream.

The decoder is reused across requests: reconfigure_decoder repoints the existing decoder at each new source instead of paying a fresh SimpleDecoder construction per request. Construction (CUVID parser + decoder + surface-pool allocation) is the dominant per-request cost, so reconfiguring is far cheaper. Decoder dimensions are bounded at construction so resolution changes do not replace its native frame pool. A single decoder serves both metadata (len/get_stream_metadata) and frame decode -- no separate metadata decoder.

Methods:

  • recover –

    Release decoder resources and drain work after a failed request.

  • reset –

    Rebuild this slot after draining only its CUDA stream.

recover()

Release decoder resources and drain work after a failed request.

reset()

Rebuild this slot after draining only its CUDA stream.

PyNvVideoCodecSourceMetadata

Bases: NamedTuple

Metadata needed before GPU video decode.

PyNvVideoCodecVideoBackendMixin

PyNvVideoCodec utilities for GPU-backed frame decode.

_PyNvDecoderPool

Process-wide singleton managing PyNvVideoCodec decoder slot state.

Prevents subclass counter shadowing (GHSA-j682-9xp5-rrf3) by storing all mutable pool state in a single module-level instance rather than in ClassVar attributes that get shadowed by Python's augmented assignment semantics on subclasses.

_get_decoder_caps(nvc, device_index, codec, chroma_format, bit_depth) cached

nvc.GetDecoderCaps, cached per device and stream format.

Each call takes ~180 ms and holds the GIL, which stalls every other request in the API process; the result only depends on these arguments. Callers must not mutate the returned dict.

_pynvvc_frames_to_nhwc(frames)

Return a stacked PyNvVideoCodec frame batch as contiguous NHWC.

_sample_nearest_keyframes(uniform_indices, key_frame_indices, total_frames)

Snap uniform sample indices to the nearest keyframes.

Keyframes decode without walking their GOP. The result stays distinct and chronological; the uniform indices are returned unchanged when there are fewer usable keyframes than targets.