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 byget_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.
width – Optional: Resize the frame.
height – Optional: Resize the frame.
pix_fmt – Optional: The output pixel format.
demux_config – Optional: Demux configuration passed to
async_demux_image()
.decode_config – Optional: Decode configuration passed to
async_decode_packets()
.filter_desc – Optional: Filter description passed to
async_decode_packets()
.device_config – Optional: The CUDA device passed to
async_transfer_buffer()
. Providing this argument will move the resulting buffer to the CUDA device.strict – Optional: If True, raise an error if any of the images failed to load.
- Returns:
A buffer object.