diff --git a/torchvision/csrc/io/decoder/decoder.cpp b/torchvision/csrc/io/decoder/decoder.cpp index f13e2c3ffcf..a895eed2d39 100644 --- a/torchvision/csrc/io/decoder/decoder.cpp +++ b/torchvision/csrc/io/decoder/decoder.cpp @@ -312,6 +312,8 @@ bool Decoder::init( } } + av_dict_set_int(&options, "probesize", params_.probeSize, 0); + interrupted_ = false; // ffmpeg avformat_open_input call can hang if media source doesn't respond diff --git a/torchvision/csrc/io/decoder/defs.h b/torchvision/csrc/io/decoder/defs.h index 502e5762e46..ba82625c309 100644 --- a/torchvision/csrc/io/decoder/defs.h +++ b/torchvision/csrc/io/decoder/defs.h @@ -213,6 +213,12 @@ struct DecoderParameters { // Skip packets that fail with EPERM errors and continue decoding. bool skipOperationNotPermittedPackets{false}; + + // probing size in bytes, i.e. the size of the data to analyze to get stream + // information. A higher value will enable detecting more information in case + // it is dispersed into the stream, but will increase latency. Must be an + // integer not lesser than 32. It is 5000000 by default. + int64_t probeSize{5000000}; }; struct DecoderHeader {