User42
User42

Reputation: 83

Grabbing frames when VideoInfoHeader2 structure

I'm working on an application that makes analysis on video files. Being no expert on DirectShow I used simple code for the analysis of all frames (SampleGrabber, Callback etc.).

This works fine for all media files, even when decoded with VideoInfoHeader2 structure (although it shouldn't, as stated everywhere).

The problem is with grabbing a single frame. For this I used IMediaDet. And this doesn't do if there's only VideoInfoHeader2, and no VideoInfoHeader.

I tried modifications of my analysis code (OneShot, Seek), but it doesn't do. All sources in the internet concerning this are not very helpful, as they point to SDK/ DX examples that aren't accessible anymore, or they just say that modification would be "easy". Well, maybe for an DX expert ... (But I need to use the car, not first to build it ... ;-)

As the matter became more & more important to me my "workaround" is to recode all videos with VideoInfoHeader2, save them with VideoInfoHeader, and do the analysis/ grabbing on that.

Very resource consuming, and the opposite of smart ... Any help appreciated.

Upvotes: 0

Views: 211

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69724

You outlined the necessary steps which are still the easiest solution (provided that you don't give up and use Windows API; using a third party library might be easier in comparison but this is beyond the scope of this question).

Sample Grabber and IMediaDet are parts of deprecated DirectShow Editing Services, development of which was stopped long ago. If you are not satisfied with stock API, you have to use a more flexible replacement. For example, you can grab source of similar Sample Grabber sample from older DirectX or Platform SDK and extend it to support VIDEOINFOHEADER2.

IMediaDet is nothing but COM class building its own graph internally trying to decode video. It is inflexible and almost every time your building your own graph is a more reliable solution.

Microsoft's answer to this problem is - as they abandoned DirectShow development - newer API Media Foundation. However there are reasons why this "answer" is not so good: limited OS compatibility, limited support for codecs and formats, completely new API which has little in common with DirectShow and you need to redesign your application.

All together, you either have to find a Sample Grabber replacement using one of the popular and explained methods (no matter they look not so much helpful), or switch to another API or third party library. Or, another possible solution is to use a different filter/codec which is capable of decoding into VIDEOINFOHEADER formatted media type.

Upvotes: 1

Related Questions