spdl.io.async_load_image_batch_nvdec¶
- async async_load_image_batch_nvdec(srcs: list[str | bytes], *, device_config: CUDAConfig, width: int | None, height: int | None, pix_fmt: str | None = 'rgba', demux_config: DemuxConfig | None = None, decode_options: dict[str, Any] | None = None, strict: bool = True, **kwargs) CUDABuffer [source]¶
[Experimental] Batch load images with NVDEC.
This function combines
demux_image()
anddecode_packets_nvdec()
to produce buffer object from source in one step.It concurrently demuxes the input images, using the
ThreadPoolExecutor
attached to the running async event loop, fetched byget_running_loop()
.- Parameters:
srcs – List of source identifiers.
device_config – The CUDA device config. See
transfer_buffer()
.width – Optional: Resize the frame.
height – Optional: Resize the frame.
pix_fmt – Optional: Change the format of the pixel.
demux_config – Optional: Demux options passed to
async_demux_media()
.decode_options – Optional: Other decode options passed to
async_decode_packets_nvdec()
.strict – Optional: If True, raise an error if any of the images failed to load.
- Returns:
A buffer object.
Example
>>> srcs = [ ... "sample1.jpg", ... "sample2.png", ... ] >>> coro = async_load_image_batch_nvdec( ... srcs, ... cuda_device_index=0, ... width=124, ... height=96, ... pix_fmt="rgba", ... ) >>> buffer = asyncio.run(coro) >>> array = spdl.io.to_torch(buffer) >>> # An array with shape NCHW==[2, 4, 96, 124] on CUDA device 0 >>>