How to change Directshow filter properties C++

血红的双手。 提交于 2019-12-28 04:33:07

问题


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.


回答1:


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:

  • Controlling variables in filter remotely
  • with out property page, How can I input a value through codes?
  • Define a Mechanism for Setting the Property on MSDN



回答2:


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,.




回答3:


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...



来源:https://stackoverflow.com/questions/14050074/how-to-change-directshow-filter-properties-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!