问题
Every example in the directshow.net samples folder (marked "2010-February") compiles fine, and those that play videos from files work great. However, every example that tries to enumerate the FilterCategory.VideoInputDevices always fails to find any of my filters, specifically DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
always returns that I have no devices. This same problem occurs for me in every other program that uses directshow.net, like touchless and the various examples on codeplex.
I've got four video input filters installed (1 webcam and 3 screen-capturing filters) and they're found/usable by the graph editor that comes with the Windows SDK and the rl Filter Manager. Both programs list the four filters under "Video Capture Sources" and each Moniker starts with the correct GUID that directshow.net's FilterCategory.VideoInputDevices points to ("860BB310-5D01-11D0-BD3B-00A0C911CE86").
I've tried compiling and using the latest directshow.net dll myself, but nothing changed.
Is there some reason why the wrapper can get the video rendering filters fine but not enumerate video capturing ones? I'm on win7 sp1, 64bit, using visual C# 2010 express. Is something in my environment causing this? I'd gladly handle the change myself if I knew what is causing it.
Thank you for your time.
回答1:
I copied the code for GetDevicesOfCat into my project and started debugging it. If I handed it any FilterCategory other than VideoInputDevice, it would get most of the filters that GraphEdit lists, but it was still missing some in most of the categories. I guessed that there was some property of the filters that made them unobtainable to my compiled version of GetDevicesOfCat.
It turns out simply switching my platform target to x86 does the trick, though it's not as straightfoward in VS2010 Express (for a fresh install, you'll have to follow the second answer before you do the first): Change target CPU settings in Visual Studio 2010 Express
The program now successfully enumerates all of my filters.
来源:https://stackoverflow.com/questions/6657873/is-directshow-net-video-input-device-filter-enumeration-broken-in-newer-environ