Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to add a video capture filter #3

Closed
Chidilives opened this issue Sep 22, 2015 · 30 comments
Closed

Failed to add a video capture filter #3

Chidilives opened this issue Sep 22, 2015 · 30 comments

Comments

@Chidilives
Copy link

Failed to add a video capture filter
Error Code 0x8004021

this Error is only happening in windows 10 machines. it still works perfectly on other OS

@jacobbo
Copy link
Owner

jacobbo commented Sep 22, 2015

I tried two different Windows 10 machines and was unable to reproduce this issue, though I am aware of it. Which camera model are you using?

@Chidilives
Copy link
Author

This Happens on both the in built camera and a Logitech c210 webcam.

@zuckerthoben
Copy link

I have the same error: Surface Pro 4 with current updates.

@wakuflair
Copy link

Win7 has the same error

@ghost
Copy link

ghost commented Nov 25, 2016

One way it occurs, if you try to use the WebCameraControl when you try to StartCapture() and the control has its Visibility set to collapsed.

If you make sure the control is visible before invoking StartCapture it will not have that error.

@jshansen
Copy link

I had the same exception when I attempt to start the capture immediately from the constructor of the window. When I initialize it from e.g. a button click, it works fine.

@YevgenijZ
Copy link

YevgenijZ commented Oct 30, 2017

This happens on any fresh Windows 8.1 machine. Windows 7, 10 is fine.
It is possible to replicate with WebCameraDemo from source files.

@jacobbo
Copy link
Owner

jacobbo commented Oct 30, 2017

What's the error's HRESULT code? 0x80040217?

@YevgenijZ
Copy link

Yes
WebEye.Controls.Wpf.DirectShowException: Failed to add a video capture filter. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80040217
--- End of inner exception stack trace ---
at WebEye.Controls.Wpf.DirectShowProxy.AddCaptureFilter(String devicePath)
at WebEye.Controls.Wpf.WebCameraControl.StartCapture(WebCameraId camera)

@jacobbo
Copy link
Owner

jacobbo commented Oct 30, 2017

Sorry, but most probably you'll have to install something to make your camera work with the control.
This could be a Windows service pack or drivers from your camera manufacturer.

This error means that some required directshow filters are missing on your machine. Here is a similar issue:
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/b3a4b061-dc10-4e72-9654-55ba55be9ae8/error-0x80040217?forum=windowsdirectshowdevelopment

@YevgenijZ
Copy link

It is on four different machines with different cameras including integrated one on laptop, pre-installed camera app works just fine.
It is fresh win8.1+NET4.5.2+all latest updates via windows update.
Looks like something systematic, but ok I'll have look what I might have missed.

@jacobbo
Copy link
Owner

jacobbo commented Oct 30, 2017

You could try GraphEdit to find out which filters are missing:
https://code.google.com/p/graph-studio-next/

@YevgenijZ
Copy link

Interesting that on Win8.1 GraphStudio inserts -> MJPEG decompressor -> Color Space Converter in between capture filter (camera) and output renderer. On Win10 it is direct play back from capture filter to renderer.
So play back works via GraphStudio but with additional elements in graph.

@jacobbo
Copy link
Owner

jacobbo commented Oct 30, 2017

That's weird. I'd assume that Win10 uses a different default driver for webcams that does MJPEG decompression internally. If this is a quite common error then a solution would be to add these filters explicitly to the graph.

@YevgenijZ
Copy link

YevgenijZ commented Oct 30, 2017

Yes, I tried to add them in win10 (in graph studio) as well and it does no harm, where on Win8.1 they are must.

@jacobbo
Copy link
Owner

jacobbo commented Oct 30, 2017

I could try to add this fix to the control at the weekend and you could test it on your machines.

@YevgenijZ
Copy link

That's would be great, you can create separate branch or whatever convenient way you prefer. Thanks.

@YevgenijZ
Copy link

Interesting thing is that graph studio somehow able to determine whether it needs to add two additional filters:
mjpeg decoder and color space converter

@jacobbo
Copy link
Owner

jacobbo commented Oct 30, 2017

Yes, that's the question: how it does that. Is it a directshow feature or something on top of it?
I use Intelligent Connect to build the graph and it fails to build it properly for your configuration.

@YevgenijZ
Copy link

YevgenijZ commented Oct 30, 2017

win81capture
Win81Capture.txt

Graph studio export of Win8.1 graph

It's from Win8 under VirtualBox, but initial problems from physical machines, I just don't have access to them right now.

@jacobbo
Copy link
Owner

jacobbo commented Oct 30, 2017

Thanks! As I said, I'll try to come up with a solution, but not earlier than this weekend.

@YevgenijZ
Copy link

Ok, finally managed to understand the issue. This is nothing to do with intermediate filters (decompressor and color converter) - RenderStream uses smart connect and able to add them if needed.
Problem is with VMR9 as final renderer which is not working for my camera on Windows 8.1 (but working on Windows 10). This is clearly visible when I explicitly use VMR9 in GraphStudioNext - smart connect is not able to create filter path from camera source to VMR9 renderer. As you said may be something wrong with drivers, I don't know.

So my solution is to fork your project and use VMR7 renderer in custom library build, I already did this and it seems to be working on both Win8.1 and Win10.

You don't need to fix anything, but if you'll have a time you can add parameters to specify which renderer to use inside DirectShowFacade.

@jacobbo
Copy link
Owner

jacobbo commented Oct 31, 2017

The video renderer on your picture, is it VMR7, not VMR9?

I do not really remember why I chose VMR9 instead of VMR7. VMR9 offers more features, but the control doesn't use any of them.

Anyway, if smart connect successfully builds graphs with VMR7 and fails to build them with VMR9, then VMR7 seems as a better fit for the control.

@YevgenijZ
Copy link

Yes, renderer on my picture is not VMR9 and even not VMR7 but even more older one because I didn't noticed that graph studio uses it by default at that moment. So ignore pictures. Then tried to use VMR9 on Win8.1 and it failed but was ok with VMR7 and EVR.
Why it failing I don't know.
On win10 you can use camera output as YUY2 directly to VMR9 or camera output as MJPG with decompression filters - both works.
On win8 YUY2 not available for any of my two cameras and MJPG to VMR9 not working. Don't know why.

You are using VMR9 - HRESULT hr = g_spRenderFilter.CoCreateInstance(CLSID_VideoMixingRenderer9);.

I would say that you can switch to VMR7 because it seems more "stable".

@jacobbo
Copy link
Owner

jacobbo commented Oct 31, 2017

What do you mean by 'stable' here? I'm interested to fix the 0x80040217 error.
Do you think replacing VMR9 with VMR7 would solve the error in your case?

@YevgenijZ
Copy link

In my case it solves error, I created custom library build with VMR7 and its working on both win8.1 and win10.

@jacobbo
Copy link
Owner

jacobbo commented Oct 31, 2017

Thanks for your feedback! I'll try VMR7 this weekend and if it works well then I'll replace VMR9.

@jacobbo
Copy link
Owner

jacobbo commented Nov 4, 2017

I've replaced VMR9 with VMR7 (Debug.zip). When you have a chance, could you please test it on your configurations?

@YevgenijZ
Copy link

I ran demo app and my app with dll from archive, both works fine on Win10, Win8.1. Thanks.

@jacobbo
Copy link
Owner

jacobbo commented Nov 5, 2017

Good, thank you.

@jacobbo jacobbo closed this as completed Nov 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants