<p dir="auto">Hi,</p>
<p dir="auto">Running opencv installed via OpenVINO on Windows and it cannot read video. Tried several formats (MP4, AVI, etc), but still getting:<br>
<code class="notranslate">MFX: Unsupported extension [ WARN:0] global opencv\modules\videoio\src\cap_msmf.cpp (680) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (352x288 @ 25) MFVideoFormat_RGB32(unsupported media type)</code><br>
I tried installing various codecs but I still have the issue.</p>
<p dir="auto">Platform info:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="4.3.0-14-g9a54a3273 (OpenVINO/2020.3)
releases/openvino/2020.3
9a54a3273da58e5992a7cf4bed1e30277f26dd22

General configuration for OpenCV 4.3.0-openvino-2020.3.0 =====================================
  Version control:               9a54a3273da58e5992a7cf4bed1e30277f26dd22

  Platform:
    Host:                        Windows 10.0.18363 AMD64
    CMake:                       3.14.5
    CMake generator:             Visual Studio 14 2015 Win64
    MSVC:                        1900"><pre class="notranslate"><code class="notranslate">4.3.0-14-g9a54a3273 (OpenVINO/2020.3)
releases/openvino/2020.3
9a54a3273da58e5992a7cf4bed1e30277f26dd22

General configuration for OpenCV 4.3.0-openvino-2020.3.0 =====================================
  Version control:               9a54a3273da58e5992a7cf4bed1e30277f26dd22

  Platform:
    Host:                        Windows 10.0.18363 AMD64
    CMake:                       3.14.5
    CMake generator:             Visual Studio 14 2015 Win64
    MSVC:                        1900
</code></pre></div>
<p dir="auto">Any help?</p>
<p dir="auto">Regards,<br>
Nedim</p>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.3.0</li>
<li>Operating System / Platform =&gt; Windows 64 Bit</li>
<li>Compiler =&gt; Visual Studio 2019</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">if I use mp4 which has no audio stream (audio stream was removed with ffmpeg), no problem.</p>
<p dir="auto">I used opencv of release windows module(4.3.0).<br>
result of code is as follows.<br>
sample files are attached.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\videoio_registry.cpp (187) cv::`anonymous-namespace'::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(7, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940)
[ WARN:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\cap_msmf.cpp (681) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (0x0 @ 1) MFVideoFormat_RGB32(unsupported media type)
ng
ok"><pre class="notranslate"><code class="notranslate">[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\videoio_registry.cpp (187) cv::`anonymous-namespace'::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(7, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940)
[ WARN:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\cap_msmf.cpp (681) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (0x0 @ 1) MFVideoFormat_RGB32(unsupported media type)
ng
ok
</code></pre></div>
<h5 dir="auto">Steps to reproduce</h5>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;opencv2/opencv.hpp&gt;
int main()
{
	cv::VideoCapture cap(&quot;sample-has-sound.mp4&quot;, cv::CAP_MSMF);
	cv::Mat image;
	if (cap.isOpened())
	{
		bool ret = cap.read(image);
		if (ret)
		{
			std::cout &lt;&lt; &quot;ok&quot; &lt;&lt; std::endl;
		}
		else
		{
			std::cout &lt;&lt; &quot;ng&quot; &lt;&lt; std::endl;
		}
	}
	cv::VideoCapture cap2(&quot;sample-no-sound.mp4&quot;, cv::CAP_MSMF);
	if (cap2.isOpened())
	{
		bool ret = cap2.read(image);
		if (ret)
		{
			std::cout &lt;&lt; &quot;ok&quot; &lt;&lt; std::endl;
		}
		else
		{
			std::cout &lt;&lt; &quot;ng&quot; &lt;&lt; std::endl;
		}
	}
} "><pre class="notranslate">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>stdio.h<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>iostream<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2/opencv.hpp<span class="pl-pds">&gt;</span></span>
<span class="pl-k">int</span> <span class="pl-en">main</span>()
{
	cv::VideoCapture <span class="pl-smi">cap</span>(<span class="pl-s"><span class="pl-pds">"</span>sample-has-sound.mp4<span class="pl-pds">"</span></span>, cv::CAP_MSMF);
	cv::Mat image;
	<span class="pl-k">if</span> (cap.<span class="pl-c1">isOpened</span>())
	{
		<span class="pl-k">bool</span> ret = cap.<span class="pl-c1">read</span>(image);
		<span class="pl-k">if</span> (ret)
		{
			std::cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>ok<span class="pl-pds">"</span></span> &lt;&lt; std::endl;
		}
		<span class="pl-k">else</span>
		{
			std::cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>ng<span class="pl-pds">"</span></span> &lt;&lt; std::endl;
		}
	}
	cv::VideoCapture <span class="pl-smi">cap2</span>(<span class="pl-s"><span class="pl-pds">"</span>sample-no-sound.mp4<span class="pl-pds">"</span></span>, cv::CAP_MSMF);
	<span class="pl-k">if</span> (cap2.<span class="pl-c1">isOpened</span>())
	{
		<span class="pl-k">bool</span> ret = cap2.<span class="pl-c1">read</span>(image);
		<span class="pl-k">if</span> (ret)
		{
			std::cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>ok<span class="pl-pds">"</span></span> &lt;&lt; std::endl;
		}
		<span class="pl-k">else</span>
		{
			std::cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>ng<span class="pl-pds">"</span></span> &lt;&lt; std::endl;
		}
	}
} </pre></div>
<p dir="auto">and I modified the code "cap_msmf.cpp" to pass only video types , it fixed;</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
   // class FormatStorage

    void read(IMFSourceReader* source)
    {
        HRESULT hr = S_OK;
        MediaID cur;
        GUID majorType;
        while (SUCCEEDED(hr))
        {
            _ComPtr&lt;IMFMediaType&gt; raw_type;
            hr = source-&gt;GetNativeMediaType(cur.stream, cur.media, &amp;raw_type);
            if (hr == MF_E_NO_MORE_TYPES)
            {
                hr = S_OK;
                cur.nextStream();
            }
            else if (SUCCEEDED(hr))
            {
                raw_type.Get()-&gt;GetMajorType(&amp;majorType);
                if (majorType == MFMediaType_Video)             // add this condition
                {
                    formats[cur] = MediaType(raw_type.Get());
                } 
                cur.nextMedia();
            }
        }
    }"><pre class="notranslate">   <span class="pl-c"><span class="pl-c">//</span> class FormatStorage</span>

    <span class="pl-k">void</span> <span class="pl-en">read</span>(IMFSourceReader* source)
    {
        HRESULT hr = S_OK;
        MediaID cur;
        GUID majorType;
        <span class="pl-k">while</span> (<span class="pl-c1">SUCCEEDED</span>(hr))
        {
            _ComPtr&lt;IMFMediaType&gt; raw_type;
            hr = source-&gt;<span class="pl-c1">GetNativeMediaType</span>(cur.<span class="pl-smi">stream</span>, cur.<span class="pl-smi">media</span>, &amp;raw_type);
            <span class="pl-k">if</span> (hr == MF_E_NO_MORE_TYPES)
            {
                hr = S_OK;
                cur.<span class="pl-c1">nextStream</span>();
            }
            <span class="pl-k">else</span> <span class="pl-k">if</span> (<span class="pl-c1">SUCCEEDED</span>(hr))
            {
                raw_type.<span class="pl-c1">Get</span>()-&gt;<span class="pl-c1">GetMajorType</span>(&amp;majorType);
                <span class="pl-k">if</span> (majorType == MFMediaType_Video)             <span class="pl-c"><span class="pl-c">//</span> add this condition</span>
                {
                    formats[cur] = <span class="pl-c1">MediaType</span>(raw_type.<span class="pl-c1">Get</span>());
                } 
                cur.<span class="pl-c1">nextMedia</span>();
            }
        }
    }</pre></div>
<p dir="auto"><a href="https://github.com/opencv/opencv/files/4687419/samples.zip">samples.zip</a></p>