spdl.io.async_load_image_batch

async async_load_image_batch(srcs: list[str | bytes], *, width: int | None, height: int | None, pix_fmt: str | None = 'rgb24', demux_config: DemuxConfig | None = None, decode_config: DecodeConfig | None = None, filter_desc: str | None = _FILTER_DESC_DEFAULT, device_config: None = None, strict: bool = True, **kwargs) CPUBuffer[source]
async async_load_image_batch(srcs: list[str | bytes], *, width: int | None, height: int | None, pix_fmt: str | None = 'rgb24', demux_config: DemuxConfig | None = None, decode_config: DecodeConfig | None = None, filter_desc: str | None = _FILTER_DESC_DEFAULT, device_config: CUDAConfig, strict: bool = True, **kwargs) CUDABuffer

Batch load images.

This function combines demux_image(), decode_packets(), convert_frames(), and optionally, transfer_buffer(), to produce buffer object from source in one step.

It concurrently demuxes and decodes the input images, using the ThreadPoolExecutor attached to the running async event loop, fetched by get_running_loop().

gantt title Illustration of asynchronous batch image decoding timeline dateFormat X axisFormat %s section Thread 1 Demux image 1 :demux1, 0, 3 Decode/resize image 1 :after demux1, 20 section Thread 2 Demux image 2 :demux2, 1, 5 Decode/resize image 2 :after demux2, 23 section Thread 3 Demux image 3 :demux3, 2, 5 Decode/resize image 3 :after demux3, 24 section Thread 4 Demux image 4 :demux4, 3, 8 Decode/resize image 4 :decode4, after demux4, 25 section Thread 5 Batch conversion :batch, after decode4, 30 Device Transfer :after batch, 33
Parameters:
  • srcs – List of source identifiers.

  • widthOptional: Resize the frame.

  • heightOptional: Resize the frame.

  • pix_fmtOptional: The output pixel format.

  • demux_configOptional: Demux configuration passed to async_demux_image().

  • decode_configOptional: Decode configuration passed to async_decode_packets().

  • filter_descOptional: Filter description passed to async_decode_packets().

  • device_configOptional: The CUDA device passed to async_transfer_buffer(). Providing this argument will move the resulting buffer to the CUDA device.

  • strictOptional: If True, raise an error if any of the images failed to load.

Returns:

A buffer object.