Merge pull request #17406 from mshabunin:fix-msmf-audio-handling

pull/17410/head
Alexander Alekhin 5 years ago
commit 4b5fdc6bb2
  1. 11
      modules/videoio/src/cap_msmf.cpp

@ -487,12 +487,14 @@ public:
}
}
}
std::pair<MediaID, MediaType> findBest(const MediaType& newType)
std::pair<MediaID, MediaType> findBestVideoFormat(const MediaType& newType)
{
std::pair<MediaID, MediaType> best;
std::map<MediaID, MediaType>::const_iterator i = formats.begin();
for (; i != formats.end(); ++i)
{
if (i->second.majorType != MFMediaType_Video)
continue;
if (newType.isEmpty()) // file input - choose first returned media type
{
best = *i;
@ -770,7 +772,12 @@ bool CvCapture_MSMF::configureOutput(MediaType newType, cv::uint32_t outFormat)
{
FormatStorage formats;
formats.read(videoFileSource.Get());
std::pair<FormatStorage::MediaID, MediaType> bestMatch = formats.findBest(newType);
std::pair<FormatStorage::MediaID, MediaType> bestMatch = formats.findBestVideoFormat(newType);
if (bestMatch.second.isEmpty())
{
CV_LOG_DEBUG(NULL, "Can not find video stream with requested parameters");
return false;
}
dwStreamIndex = bestMatch.first.stream;
nativeFormat = bestMatch.second;
MediaType newFormat = nativeFormat;

Loading…
Cancel
Save