title: How can I read the info of a media file using visual c++?
body: <p>Is there a way to read the info (fps, bitrate, duration, codecs required, etc.) of a media file (avi, mp4, mkv, etc.) on windows using visual studio c++?</p>
  
  <p>I managed to play various files (which I actually don't even want) using directshow (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd389098%28v=vs.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/dd389098%28v=vs.85%29.aspx</a>) but I don't know how to only get the information from the file.</p>
  
  <p>Edit: I got it working like this...</p>
  
  <pre><code>int             height, width, framerate, bitrate;
  LARGE_INTEGER   duration;
  
  // initialize the COM library
  CoInitialize(NULL);
  
  // 
  IPropertyStore* store = NULL;
  SHGetPropertyStoreFromParsingName(L"E:\\test.avi", NULL, GPS_DEFAULT, __uuidof(IPropertyStore), (void**)&amp;store);
  
  PROPVARIANT variant;
  
  store-&gt;GetValue(PKEY_Media_Duration, &amp;variant);
  duration = variant.hVal;
  store-&gt;GetValue(PKEY_Video_FrameHeight, &amp;variant);
  height = variant.lVal;
  store-&gt;GetValue(PKEY_Video_FrameWidth, &amp;variant);
  width = variant.lVal;
  store-&gt;GetValue(PKEY_Video_FrameRate, &amp;variant);
  framerate = variant.lVal;
  store-&gt;GetValue(PKEY_Video_TotalBitrate, &amp;variant);
  bitrate = variant.lVal;
  // 
  store-&gt;Release();
  //
  CoUninitialize();
  </code></pre>