spdl.io.decode_packets_nvdec

decode_packets_nvdec(packets: VideoPackets, *, device_config: CUDAConfig, pix_fmt: str = 'rgb', crop_left: int = 0, crop_top: int = 0, crop_right: int = 0, crop_bottom: int = 0, scale_width: int = -1, scale_height: int = -1) CUDABuffer[source]

[Experimental] Decode packets with NVDEC.

This function allocates a single contiguous buffer upfront based on the packet count, reducing memory allocator overhead for better performance.

Warning

This API is exmperimental. The performance is not probed, and the specification might change.

Changed in version 0.0.10:

  • The alpha channel was removed, and the supported format values were changed from "rgba" and "bgra" to "rgb" and "bgr".

  • width and height options were renamed to scale_width and scale_height.

Note

Unlike FFmpeg-based decoding, NVDEC returns GPU buffer directly.

See also

NvDecDecoder: The underlying decoder implementation, which supports incremental decoding.

Parameters:
  • packets – Packets object.

  • device_config – The device to use for decoding. See spdl.io.cuda_config().

  • crop_left (int) – Optional: Crop the given number of pixels from each side.

  • crop_top (int) – Optional: Crop the given number of pixels from each side.

  • crop_right (int) – Optional: Crop the given number of pixels from each side.

  • crop_bottom (int) – Optional: Crop the given number of pixels from each side.

  • scale_width (int) – Optional: Resize the frame. Resizing is done after cropping.

  • scale_height (int) – Optional: Resize the frame. Resizing is done after cropping.

  • pix_fmt (str or None) – Optional: Change the format of the pixel. Supported value is "rgb" and "bgr". Default: "rgb".

Returns:

A CUDABuffer object with shape [num_frames, 3, height, width].