select correct MediaType in MSMF backend.
authorMENG Yu <m3nciu5@outlook.com>
Fri, 5 Aug 2022 17:52:33 +0000 (01:52 +0800)
committerMENG Yu <m3nciu5@outlook.com>
Mon, 22 Aug 2022 04:09:28 +0000 (12:09 +0800)
modules/videoio/src/cap_msmf.cpp

index d3002a5..0b46be1 100644 (file)
@@ -347,6 +347,12 @@ struct MediaType
         }
         return false;
     }
+    bool VideoIsAvailable() const
+    {
+        return ((subType == MFVideoFormat_RGB32) ||
+            (subType == MFVideoFormat_RGB24) ||
+            (subType == MFVideoFormat_YUY2));
+    }
 };
 
 void printFormat(std::ostream& out, const GUID& fmt)
@@ -627,7 +633,7 @@ public:
         {
             if (i->second.majorType == MFMediaType_Video)
             {
-                if (best.second.isEmpty() || i->second.VideoIsBetterThan(best.second, newType))
+                if (best.second.isEmpty() || (i->second.VideoIsBetterThan(best.second, newType) && i->second.VideoIsAvailable()))
                 {
                     best = *i;
                 }