VedioCapture encountered an API version issue when reading video files

I am using VedioCapture for video reading and writing, and the second parameter is specified in capture.open as CAP_MSMF. But it will prompt an error. Below is the error message

[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\videoio_registry.cpp (197) cv::`anonymous-namespace'::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(8, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930)

[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (396) cv::impl::getPluginCandidates Found 2 plugin(s) for MSMF

[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (175) cv::impl::DynamicLib::libraryLoad load C:\OPENCV451\opencv\build\x64\vc15\bin\opencv_videoio_msmf451_64d.dll => OK

[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (245) cv::impl::PluginBackend::PluginBackend Video I/O: initialized 'Microsoft Media Foundation OpenCV Video I/O plugin': built with OpenCV 4.5 (ABI/API = 0/0), current OpenCV version is '4.5.1' (ABI/API = 0/1)

[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (256) cv::impl::PluginBackend::PluginBackend Video I/O: NOTE: plugin is supported, but there is API version mismath: plugin API level (0) != OpenCV API level (1)

[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (259) cv::impl::PluginBackend::PluginBackend Video I/O: NOTE: some functionality may be unavailable due to lack of support by plugin implementation

[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (262) cv::impl::PluginBackend::PluginBackend Video I/O: plugin is ready to use 'Microsoft Media Foundation OpenCV Video I/O plugin'

[ INFO:1] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (181) cv::impl::DynamicLib::libraryRelease unload C:\OPENCV451\opencv\build\x64\vc15\bin\opencv_videoio_msmf451_64d.dll

May I ask where is the problem?

Code:

VideoCapture capture;
    capture.open("D:\\tg.mp4",CAP_MSMF);
    if (capture.isOpened())
    {
        mat = capture.grab();

welcome.

is capture.isOpened() true?

all those messages are INFO messages.

I’ve reformatted your post so your code is presented as actual code, and the escaped backslash is displayed properly.

Thank, I modified the code and made some judgments, and found that the content of mat is null. Now I understand why this happens.

oh also, call capture.read() if you want an actual frame.

capture.grab() by itself doesn’t give you a frame.

please read the documentation on these methods.

Yes 。So I changed my wording to: while(capture.read(mat))。Now,is working