spdl.io.decode_config

decode_config(**kwargs) DecodeConfig[source]

Customize decoding behavior.

Parameters:
  • decoder (str) – Optional Override decoder.

  • decoder_options (dict[str, str]) – Optional Provide decoder options

Returns:

Config object.

Example: Specifying the decoder for H264

>>> # Use libopenh264 decoder to decode video
>>> cfg = DecodeConfig(decoder="libopenh264")
>>>
>>> frames = await spdl.io.async_decode_packets(
...     await spdl.io.async_demux_media("video", src),
...     decode_config=cfg)

Example: Change the number of threads internal to FFmpeg decoder

>>> # Let FFmpeg chose the optimal number of threads for decoding.
>>> # Note: By default, SPDL specifies decoders to use a single thread.
>>> cfg = DecodeConfig(decoder_options={"threads": "0"})
>>>
>>> frames = await spdl.io.async_decode_packets(
...     await spdl.io.async_demux_video(src),
...     decode_config=cfg)