I have being using MediaInfoLib, to find duration of a media file, in my project without issue until I observed lately that when I try to parse multiple large video files ( MXF, MP4 and AVI formats) quickly in a loop, MediaInfo is unable to return all the information. My C++ project snippet is produced below. I have tried waiting till the mediaInfoDll object is ready. All the skipped video files work if they are individually parsed. Any clue? I found ffprobe application to be too slow and vlc library is not accurate for different media types. Thanks
bool getMediaInfo(CString filename, long& duration)
{
MediaInfoDLL::MediaInfo movieInfo;
if( movieInfo.Open(filename.GetString())) return false;
std::chrono::high_resolution_clock::time_point start =
std::chrono::high_resolution_clock::now();
while (true) {
std::chrono::high_resolution_clock::time_point present = std::chrono::high_resolution_clock::now();
std::chrono::seconds lapse = std::chrono::duration_cast<std::chrono::seconds>(present - start);
if (lapse >= std::chrono::seconds(3)) {
movieInfo.Close();
return false;
}
if (!movieInfo.IsReady()) continue;
auto strDura = movieInfo.Get(MediaInfoDLL::Stream_General, 0, L"Duration"); //in msec
duration = std::atol(CStringA(strDura.c_str()));
movieInfo.Close();
break;
}
return true;
}