3

How to change Filter Properties programmatically?

I am using a filter AAC encoder, and I can manually change its bitrate in graphedit by right clicking on the filter and entering the bitrate value.

Is it possible to do the same through code?

Please give me valuable suggestions and if possible with code.

jogojapan
  • 68,383
  • 11
  • 101
  • 131
Shiva Kumar
  • 389
  • 3
  • 22

3 Answers3

3

You do this via private filter-specific interface. You need to refer to filter documentation or SDK to get details on this (VSS Tech Support). Sometimes you can obtain the necessary information from type library.

See:

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • so there's no generic way that's like "enumerate all options" basically you either have to display a ISpecifyPropertyPages then persist the filter's setting after that (ref: http://microsoft.public.multimedia.directx.dshow.programming.narkive.com/ldOko8Js/ispecifypropertypages-saving-and-restoring-settings), or have to refer to some third party filter specific interface? – rogerdpack Jan 13 '15 at 17:24
  • 1
    There is no mandatory filter interface that exposes generic properties, esp. named. So filters are supposed to implement something making sense for a developer... and it appears to be vendor dependant. Some might, for instance, implement `IPersistPropertyBag` but it's rare. In most cases it is just a filter specific interface. – Roman R. Jan 13 '15 at 18:30
  • Thanks Roman, your stackoverflow responses are the only reason I understand dshow today :) – rogerdpack Jan 13 '15 at 20:12
  • I found out that when you're dealing with an undocumented filter, you can see what interfaces it implements by opening the filter properties in graphedit or graphbuilder and then by looking at the interfaces tab. I think this can be a good starting point for googling more about those interfaces and learning what you can do with them. – Redoman Oct 27 '20 at 06:12
1

Your AAC Encoder will have some interface exposed through some IID's. Make sure you get that IID's interface, then access to its additional functions like bitrate, sampling rate, etc,.

Spark
  • 188
  • 1
  • 10
1

Similar to Roman's answer, it seems there are two ways that a filter's "special properties" are typically set and/or saved.

One is to display its properties page "dialog" (ISpecifyPropertyPages), then allow the user to change things and close it, then afterward you get its IPersistStream interface, and save off its "current state" which you can then use later for basically settings its properties back to what they were saved to (this is how graphedit does it, ref: http://microsoft.public.multimedia.directx.dshow.programming.narkive.com/ldOko8Js/ispecifypropertypages-saving-and-restoring-settings) In addition, you can serialize "the whole graph" to a file by calling IPersistStream on the graph object itself. See https://stackoverflow.com/a/11781370/32453

The other way is to know "exactly what type of special filter it is" and cast it to some special interface that you know of, from the third party, which may expose getters and setters, etc. like the "avisynth" filter from the Windows SDK directshow examples exposes ISynth interface

See also here which lists a few more ways apparently...here also seems related. IPersist itself also has multiple interfaces that inherit from it, see comments here. By far in my experience for dshow devices, they typically implement only IPersist and IPersistStream (and IAMSpecificPropertyPages), though you could save away values yourself for other common interfaces as well (like IAMVideoProcAmp), then manually re-set properties as well...

Update: unfortunately though many filters implement IPersistStream, it seems that few of them actually use it for anything useful...

Community
  • 1
  • 1
rogerdpack
  • 62,887
  • 36
  • 269
  • 388