spdl.io.decode_packets¶
- decode_packets(packets: AudioPackets, filter_desc: str | None = _FILTER_DESC_DEFAULT, decode_config: DecodeConfig | None = None, *, num_frames: int = -1) AudioFrames[source]¶
- decode_packets(packets: VideoPackets, filter_desc: str | None = _FILTER_DESC_DEFAULT, decode_config: DecodeConfig | None = None, *, num_frames: int = -1) VideoFrames
- decode_packets(packets: ImagePackets, filter_desc: str | None = _FILTER_DESC_DEFAULT, decode_config: DecodeConfig | None = None, *, num_frames: int = -1) ImageFrames
Decode packets.
- Parameters:
packets (AudioPackets, VideoPackets or ImagePackets) – Packets object.
filter_desc (str) –
Optional: Custom filter applied after decoding. To generate a description for common media processing operations, use
get_filter_desc()(if you have a packets object that has the timestamp set),get_audio_filter_desc(), orget_video_filter_desc(). IfNoneis provided, then filtering is disabled.Note
When decoding image/video packets, by default color space conversion is applied so that the output pixel format is rgb24. If you want to obtain frames without color conversion, disable filter by providing
filter_desc=None, or specifypix_fmt=Nonein the filter desc factory function.decode_config (DecodeConfig) – Optional: Custom decode config. See
decode_config(),
- Returns:
Frames object.
Note
The decoder thread configuration can significantly affect video decoding performance. By default, SPDL uses a single thread for decoding. You can customize this via
decode_configusingdecoder_options={"threads": "X"}, whereXis the number of threads (or"0"to let FFmpeg choose automatically).The optimal configuration depends on your workload’s characteristics. For benchmarking different thread configurations, see Benchmark video.