0

New (as in 4 days) to DirectShow. I have a filtergraph working and code written that lets me choose a camera, set it's resolution, preview it's video, compress it using XVID codec and save it to an AVI file.

How can I get the frames as byte arrays as they are coming out of the videocompressor filter in the graph?

I need to save the compressed frames to a file where the video frames are muxed with other scientific data.

The file format being used is HDF5 and the camera frames need to be interleaved with frames from other scientific instruments as they are received so they can be played back in the same order as they were received. I have this working for all device, except the webcams.

For playback, I need to feed the FilterGraph from one of the streams in the data file. Any advice on that would also be welcome!

Thanks in advance!

PetrKlapka
  • 43
  • 4

1 Answers1

1

DirectShow filters exchange data with peer filter or handle internally, it is behavior by design that you cannot obtain data stream, at least in uniform way. More on this here: Data Flow in the Filter Graph.

Sample Grabber Filter has over years been the most popular method to get access to data externally in the point of interest in the pipeline. There is a lot of code snippets out there, including StackOverflow, on how to use Sample Grabber. Sadly, it is no longer available in most recent (server?) OSes, however old SDKs have a variant of Sample Grabber in source code. I believe you can use it to get compresses bytes.

For playback, I need to feed the FilterGraph from one of the streams in the data file. Any advice on that would also be welcome!

To play data back, you need to stream the data from one of the standard container formats, in which case you can leverage existing filters, or you can inject your data yourself into DirectShow pipeline. For the latter, you need a custom filter as well since as I mentioned from the very start it's only filters which exchange data with other filters, and not controlling higher level code. Push Source Filters Sample is typical starting point for those who go the path of custom filter. Perhaps you could be better of simply writing data to AVI and then reading (playing) back from there.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thanks Roman. This appears to be the web wide consensus. I've found two filters written by a predecessor aptly named "Push" and "Dump" that appear to do what I need, but I'll need to wrap them (we are developing in C# and using DirectShow.net) and figure out why EditGraph and other such tools are unable to see the custom interfaces on these filters. – PetrKlapka Oct 15 '15 at 16:21