Need to build OpenCV "with FFMPEG", can't have cmake download files (no internet connection)

I am creating a project in c++ with QtCreator (5.14.1, MingGW compiler) and trying to use OpenCv (3.4.16) to read video files. I have tried many files of standard formats and codecs (H.264, yuv420, .mov etc). However, no matter what I try, VideoCapture() always silently fails. It doesn’t crash or show any error code, instead isOpened() is just always false.

I think the cause is that I am building opencv (via this tutorial How to setup Qt and openCV on Windows - Qt Wiki) without internet connection (I cannot have internet connection on this machine, so please do not ask me to) and therefore it can’t download the FFMPEG libraries during this process. I have been looking everywhere for information about how to download the FFMPEG libraries for opencv directly but I haven’t had any luck.

Can someone please explain what libraries I need to download and how opencv goes about looking for them? because at the moment I don’t know what I need, nor where to put them, and I cant find any information on the topic.

Or, can someone explain why calling VideoCapture(“”, cv::CAP_ANY) doesn’t have any effect? (despite being able to play the video easily in VLC, MediaPlayer etc).

int main()
VideoCapture cap(“C://”);
//VideoCapture cap(“C:/”);
//VideoCapture cap(“C:\”);
//VideoCapture cap(“C:\”);

if (!cap.isOpened()){
    cout << "Error opening video stream or file"<< endl;
    return -1;


If you have another machine with internet access, I would try genereating the build files, which downloads the ffmpeg dll’s, I would then try using these by manually copying them accross to your machine without internet access. That said if you can manually copy accross I would just build on the machine with internet access and copy to the machine without.

Okay, ill try that. Not an opencv question I know, but would opencv then correctly use ffmpeg without any further specifications? or do I still need to set it up in my QtCreator project?

Honestly I don’t know as I haven’t tried it. The VideoCapture backends have used plugins since videoio: FFmpeg plugin support on Win32 by alalek · Pull Request #14774 · opencv/opencv · GitHub, so theoretically if your building from commits after that even if OpenCV doesn’t know about the FFmpeg dll at compile time it may be able to load it as long as its on your path or in the same directory as your executable.


In the end I used this guys answer,

Just note that some of the directories are a little different now. You don’t need to put them in a folder named after the hash, or in a ‘download’ subdirectory, and you need to copy all of them to opencv-build/3rd party/ffmpeg/. I also put them in opencv/source/3rd party/ffmpeg, but not sure if I needed to do that. Finally you need to go into the ffmpeg.cmake file and set ‘status’ to TRUE when the download fails (or just remove the download part altogether), this lets it call ffmpeg_version.cmake and set things up.

1 Like