Reputation: 845
I want to extract video properties from the media file. More precisely, I am interested in:
width, height, duration, frame rate, bit rate, frame count, codec.
So far what I have done:
I have built the GraphBuilder (pGraph).
I get duration from IMediaSeeking interface.
I get frame count dynamically as decoder is decoding frames using ISampleGrabber
I managed to get height, width and an average sample duration (and calculate frame rate = avg sample duration * sample count) from IBasicVideo interface but it is working only when I call pGraph->RenderFile() on the GraphBuilder. When I use pGraph->AddSourceFilter() method to add a source this option does not work.
So my question is: Is there a good way to get all of these information at once or not. If there is no, please tell me how do I extract the rest of properties (just to recall, I already have frame count and duration)
Upvotes: 2
Views: 1386
Reputation: 69724
You can extract such information from media types of connected pins in the filter graph. With or without sample grabber, or with multiple sample grabbers. Use of sample grabber(s) eases this by offering you ISampleGrabber::GetConnectedMediaType
to access pin connection media type immediately.
The connection between demultiplexer and decoder (that is, decoder input) has a media type with codec (subtype and BITMAPINFOHEADER::biCompression fields), bitrate, resolution.
You can check the values out easily interactively with GraphStudioNext as well (the same is accessible programmatically of course).
DirectShow Editing Services offers you Media Detector (MediaDet)
which offers easy access to some details. I don't recommend using it for the reason of it being inflexible and being actually the same wrapper over DirectShow filter graph, which does exactly what I mentioned above: going over the connections and extracting values to expose them to the caller.
Upvotes: 1