# VedioCapture encountered an API version issue when reading video files

**URL:** <https://forum.opencv.org/t/vediocapture-encountered-an-api-version-issue-when-reading-video-files/2150>\
**Category:** C++\
**Tags:** windows, videoio\
**Created:** [March 14, 2021, 3:13pm UTC](https://forum.opencv.org/t/vediocapture-encountered-an-api-version-issue-when-reading-video-files/2150 "2021-03-14T15:13:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MeGuMinEx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/meguminex/32/1402_2.png) [@MeGuMinEx](https://forum.opencv.org/u/MeGuMinEx)\
**Post date:** [March 14, 2021, 3:13pm UTC](https://forum.opencv.org/t/vediocapture-encountered-an-api-version-issue-when-reading-video-files/2150/1 "2021-03-14T15:13:26Z")

</div>

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：

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

```

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 14, 2021, 3:35pm UTC](https://forum.opencv.org/t/vediocapture-encountered-an-api-version-issue-when-reading-video-files/2150/2 "2021-03-14T15:35:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MeGuMinEx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/meguminex/32/1402_2.png) [@MeGuMinEx](https://forum.opencv.org/u/MeGuMinEx)\
**Post date:** [March 14, 2021, 4:06pm UTC](https://forum.opencv.org/t/vediocapture-encountered-an-api-version-issue-when-reading-video-files/2150/3 "2021-03-14T16:06:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 14, 2021, 6:01pm UTC](https://forum.opencv.org/t/vediocapture-encountered-an-api-version-issue-when-reading-video-files/2150/4 "2021-03-14T18:01:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MeGuMinEx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/meguminex/32/1402_2.png) [@MeGuMinEx](https://forum.opencv.org/u/MeGuMinEx)\
**Post date:** [March 14, 2021, 7:02pm UTC](https://forum.opencv.org/t/vediocapture-encountered-an-api-version-issue-when-reading-video-files/2150/5 "2021-03-14T19:02:47Z")

</div>

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