diff --git a/torchvision/csrc/io/decoder/decoder.cpp b/torchvision/csrc/io/decoder/decoder.cpp index 6c9a3cdf825..a6361ca79ce 100644 --- a/torchvision/csrc/io/decoder/decoder.cpp +++ b/torchvision/csrc/io/decoder/decoder.cpp @@ -1,5 +1,6 @@ #include "decoder.h" #include +#include #include #include #include @@ -196,8 +197,10 @@ int64_t Decoder::seekCallback(int64_t offset, int whence) { void Decoder::initOnce() { static std::once_flag flagInit; std::call_once(flagInit, []() { +#if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0 av_register_all(); avcodec_register_all(); +#endif avformat_network_init(); // register ffmpeg lock manager av_lockmgr_register(&ffmpeg_lock); @@ -397,10 +400,14 @@ bool Decoder::init( } bool Decoder::openStreams(std::vector* metadata) { - for (int i = 0; i < inputCtx_->nb_streams; i++) { + for (unsigned int i = 0; i < inputCtx_->nb_streams; i++) { // - find the corespondent format at params_.formats set MediaFormat format; +#if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0 const auto media = inputCtx_->streams[i]->codec->codec_type; +#else // FFMPEG 4.0+ + const auto media = inputCtx_->streams[i]->codecpar->codec_type; +#endif if (!mapFfmpegType(media, &format.type)) { VLOG(1) << "Stream media: " << media << " at index " << i << " gets ignored, unknown type";