0

I am rendering a video file with a FilterGraph consisting of a VMR9 instance. The FilterGraph is created automatically with GraphBuilder->RenderFile(). Basically my setup is described here: http://www.codeproject.com/Articles/9206/Using-the-DirectShow-Video-Mixing-Renderer-filte

The thing is: I would like to detect some video internals like FPS, duration etc. After the call to RenderFile() the video is displayed correctly with MediaControl->StopWhenReady() and plays with Run() and Pause(). To detect the frame rate I try to grab the AM_MEDIA_TYPE struct from the VMR9's input pin:

VRM->FindPin("VMR Input0", pin); // S_OK
pin->ConnectionMediaType(&mt); // VFW_E_NOT_CONNECTED

In my opinion the filter graph should be created correctly with a call to RenderFile() and therefore this pin should be connected to my input stream. Why is it not the case and what is the way to proceed in this matter?

Microsoft provides some functions (http://msdn.microsoft.com/en-us/library/windows/desktop/dd375791%28v=vs.85%29.aspx) to traverse the graph and look for specific interfaces like IID_IAMStreamConfig that would allow the access to AM_MEDIA_TYPE. But these options fail in my implementation. The only pin I can access is the above mentioned.

Thanks in advance!

Roman R.
  • 68,205
  • 6
  • 94
  • 158
japedo
  • 368
  • 3
  • 15

1 Answers1

1

You are coming from the assumption that filter and pin, interfaces of which you hold, are connected and they are exactly the objects you are interested in. This is not necessarily true and quite a few question in past showed that people incorrectly understand the topologies they create. You need to review the filter graph and ensure you have what you expect to have. See on this: How can I reverse engineer a DirectShow graph?

One you have proper pin connection, indeed you need to use ConnectionMediaType and then go through AM_MEDIA_TYPE to VIDEOINFOHEADER or VIDEOINFOHEADER2 and then AvgTimePerFrame member.

Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thank you! Indeed the graph does not look like what I have expected. This solution http://msdn.microsoft.com/en-us/library/windows/desktop/dd377551%28v=vs.85%29.aspx worked for me. – japedo Nov 27 '14 at 08:21