From d464d4076b945f3e82d99d149ec5bc319c6906bb Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Wed, 20 Nov 2024 14:41:52 +0000 Subject: [PATCH] [Cherry-pick for 0.1.0] Raise error when num_ffmpeg_threads is None (#401) (#402) --- src/torchcodec/decoders/_video_decoder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/torchcodec/decoders/_video_decoder.py b/src/torchcodec/decoders/_video_decoder.py index bd1022de..7930756a 100644 --- a/src/torchcodec/decoders/_video_decoder.py +++ b/src/torchcodec/decoders/_video_decoder.py @@ -47,6 +47,7 @@ class VideoDecoder: Use 1 for single-threaded decoding which may be best if you are running multiple instances of ``VideoDecoder`` in parallel. Use a higher number for multi-threaded decoding which is best if you are running a single instance of ``VideoDecoder``. + Passing 0 lets FFmpeg decide on the number of threads. Default: 1. device (str or torch.device, optional): The device to use for decoding. Default: "cpu". @@ -88,6 +89,9 @@ def __init__( f"Supported values are {', '.join(allowed_dimension_orders)}." ) + if num_ffmpeg_threads is None: + raise ValueError(f"{num_ffmpeg_threads = } should be an int.") + core.scan_all_streams_to_update_metadata(self._decoder) core.add_video_stream( self._decoder,