From the command line, that way I can set FFMPEG_DIR=...
and then run cmake.exe ... .. OPENCV_FFMPEG_USE_FIND_PACKAGE=ON
Although I would have thought you should be able to achieve the same thing in the GUI if you add OPENCV_FFMPEG_USE_FIND_PACKAGE using Add Entry not Environment. The only problem is you then have to configure again and it might not pick up this additional variable.
Yes inside cmake-gui you can edit environment variables. I previously set the varibles in the Windows UI for environmental variables, which led them to appear in the Environment Editor of Cmake-gui. With cmd set you can achieve the same.
This might be the issue. I tried opening the gui with cmd, but added the OPENCV_FFMPEG_USE_FIND_PACKAGE=ON Flag. No difference.
but it set FFMPEG_FOUND to FALSE so package “FFMPEG” is considered to be
NOT FOUND.
Call Stack (most recent call first):
modules/videoio/cmake/init.cmake:7 (include)
modules/videoio/cmake/init.cmake:11 (add_backend)
cmake/OpenCVModule.cmake:298 (include)
cmake/OpenCVModule.cmake:361 (_add_modules_1)
cmake/OpenCVModule.cmake:385 (ocv_glob_modules)
CMakeLists.txt:931 (ocv_register_modules)
I don’t know what you are doing differently, I just tried again from scratch setting OPENCV_FFMPEG_USE_FIND_PACKAGE=ON and FFMPEG_DIR to the directory containing the cmake script inside of the cmake gui and it picked up FFmpeg straight away.
Does your FFmpeg directory sturcture look similar to the below?
bin
- avcodec-59.dll
- ...
cmake
- ffmpeg-config.cmake
doc
...
I must have casually extracted the folder there and forgot about the original zip folder, so the dir cmake was not with bin in one dir.
However, now I moved them in an structure like this:
\bin\
\cmake\
ffmpeg-config.cmake
\docs\
...
This gives me a new output, FFmpeg is found, but disabled:
Found FFMPEG: C:/Users/NvidiaPC/FFMPEG_BUILD/ffmpeg-n5.1-latest-win64-gpl-shared-5.1/include (found version "5.1-9-g4e4cc6e56a-20220821") found components: avutil swresample swscale avcodec avformat avfilter avdevice
FFMPEG is disabled. Can't find suitable libavcodec library (minimal 54.35.0, found #define LIBAVCODEC_VERSION_MINOR 37;#define LIBAVCODEC_VERSION_MICRO 100.37.100).
FFMPEG is disabled. Can't find suitable libavformat library (minimal 54.20.4, found #define LIBAVFORMAT_VERSION_MINOR 27;#define LIBAVFORMAT_VERSION_MICRO 100.27.100).
FFMPEG is disabled. Can't find suitable libswscale library (minimal 2.1.1, found #define LIBSWSCALE_VERSION_MINOR 7;#define LIBSWSCALE_VERSION_MICRO 100.7.100).
FFMPEG libraries version check failed (minimal libav release 9.20, minimal FFMPEG release 1.1.16).
FFMPEG: NO (find_package)
avcodec: YES (#define LIBAVCODEC_VERSION_MINOR 37 #define LIBAVCODEC_VERSION_MICRO 100.37.100)
avformat: YES (#define LIBAVFORMAT_VERSION_MINOR 27 #define LIBAVFORMAT_VERSION_MICRO 100.27.100)
avutil: YES (57.28.100)
swscale: YES (#define LIBSWSCALE_VERSION_MINOR 7 #define LIBSWSCALE_VERSION_MICRO 100.7.100)
avresample: NO
I can build OpenCV now, but I can’t use ist anymore.
On Windows I use VS Code with a CMakeLists.txt Configuration.
I can run normal C++ Code with no problem so far, but as soon as I add an OpenCV function (or even cv::Mat), the build exits with 0, but the whole code isn’t executed anymore, there is also no error message.
It may be that you haven’t added the path to the FFmpeg dll’s to your path, but in that case you would normally see an error informing you which dll is missing. Either way if you haven’t added the bin directory to your path you need to.
Thanks a lot, that fixed the problem with the cv::VideoCapture(). I can now open the Camera like this:
cv::VideoCapture cam("video=Microsoft® LifeCam HD-3000", cv::CAP_FFMPEG);
// cam.set(cv::CAP_PROP_FORMAT, -1); // If activated camera Window is about 1 px high and as wide as my screen
I tested also with cv::cudacodec::VideoReader() and there I get:
OpenCV(4.6.0) C:\...\private.cuda.hpp:112: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'
I also looked up the post from @alex to this problem:
I did that, but it still gives me the error message.
Should I open up a new thread for this problem or could this be related?
That error implies that VideoCapture inside of VideoReader failed to open the stream, however I can’t think of a reason why because the below worked for you
Is there any additional error messages?
Have you tried stepping through the code to see what is happening?
Do you get any additional info if you set the following environmental variables?
OPENCV_LOG_LEVEL=DEBUG
OPENCV_VIDEOIO_DEBUG=1
That’s strange, if you reach that warning VideoCapture has opened the web cam and you should not have fallen through to try CuvidVideoSource and see the previous error.
If I were you I would step through the code and see what is throwing an exception inside