From ec24944a03d696c70047254a0be8cc2387668452 Mon Sep 17 00:00:00 2001 From: romanmeta Date: Tue, 10 Sep 2024 15:12:01 -0700 Subject: [PATCH] Pass thread count to ffmpeg's filtergraph (#209) --- src/torchcodec/decoders/_core/VideoDecoder.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/torchcodec/decoders/_core/VideoDecoder.cpp b/src/torchcodec/decoders/_core/VideoDecoder.cpp index 5aaffbd1..2dceaff4 100644 --- a/src/torchcodec/decoders/_core/VideoDecoder.cpp +++ b/src/torchcodec/decoders/_core/VideoDecoder.cpp @@ -254,6 +254,9 @@ void VideoDecoder::initializeFilterGraphForStream( } filterState.filterGraph.reset(avfilter_graph_alloc()); TORCH_CHECK(filterState.filterGraph.get() != nullptr); + if (options.ffmpegThreadCount.has_value()) { + filterState.filterGraph->nb_threads = options.ffmpegThreadCount.value(); + } const AVFilter* buffersrc = avfilter_get_by_name("buffer"); const AVFilter* buffersink = avfilter_get_by_name("buffersink"); enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE};