using screen-capture-recorder with wpfmediakit VideoCaptureElement

1,736 views
Skip to first unread message

Dave Horner

unread,
Sep 17, 2011, 1:46:17 AM9/17/11
to roger-projects
Hello!

I was interested in trying to this the video and audio capture
working. I did manage to get some tests working using the ffmpeg that
came bundled. Other versions of ffmpeg failed to see the device.

I really would like to use this filter with the VideoCaptureElement in
wpf mediakit. http://wpfmediakit.codeplex.com/


However, when I try to select the device, I get the following
exception:
{"Failed to get IAMStreamConfig"}
At lines:
/* Get the AMMediaType for the video out pin */
hr = videoStreamConfig.GetFormat(out media);
DsError.ThrowExceptionForHR(hr);

Wondering if you get a similar error yourself if you try running the
WebCamPlayerWindow.xaml sample within the WPFMediaKit solution?

Thanks!
---dave
http://dave.thehorners.com/

Roger Pack

unread,
Sep 17, 2011, 3:11:50 AM9/17/11
to roger-p...@googlegroups.com
On Fri, Sep 16, 2011 at 11:46 PM, Dave Horner <daveyd...@gmail.com> wrote:
Hello!

I was interested in trying to this the video and audio capture
working.  I did manage to get some tests working using the ffmpeg that
came bundled.  Other versions of ffmpeg failed to see the device.

How old are they? I know dshow support is fairly new...
which version of the video capture do you have installed?
I did release a newer version earlier today that did the pins a little bit better but didn't change IAMStreamConfig
at all.  But you could try it to see if it helps.
I'll try your suggestion of checking it next time I'm in the office.
Have you been able to get it to work with any other device (like a webcam) at all?
 

I really would like to use this filter with the VideoCaptureElement in
wpf mediakit.  http://wpfmediakit.codeplex.com/


However, when I try to select the device, I get the following
exception:
{"Failed to get IAMStreamConfig"}
At lines:
           /* Get the AMMediaType for the video out pin */
           hr = videoStreamConfig.GetFormat(out media);
           DsError.ThrowExceptionForHR(hr);

Wondering if you get a similar error yourself if you try running the
WebCamPlayerWindow.xaml sample within the WPFMediaKit solution?

Wow MediaKit looks fascinating.


What does your code look like for VideoCaptureElement? (not that I have it working, mind you, just wondering).

Cheers!
-roger-

Dave Horner

unread,
Sep 17, 2011, 10:19:33 AM9/17/11
to roger-projects
Yes Mediakit is great. In fact, the code is very straight forward,
below is a combobox which shows all the video capture devices, it is
bound to the VideoCaptureDevice. That is enough. :)
<StackPanel>
<ComboBox x:Name="videoCapDevices"
ItemsSource="{Binding Source={x:Static
mediakit:MultimediaUtil.VideoInputDevices}}"
DisplayMemberPath="Name" Margin="0, 2, 0,0" />
<mediakit:VideoCaptureElement x:Name="vidCap"
EnableSampleGrabbing="True" MinWidth="100" MinHeight="100"
LoadedBehavior="Play" DesiredPixelWidth="320"

DesiredPixelHeight="240"
Stretch="Fill"

VideoCaptureDevice="{Binding Path=SelectedItem,
ElementName=videoCapDevices}"
FPS="30"/>
</StackPanel>
</Grid>

Yes, I did try the other capture devices and my webcam worked fine.
I'm wondering is this might have to do with format size......it wants
to cap my whole screen at 1920x1200, was gonna try playing with
registry settings.

As for ffmpeg, I tried the static 64bit build.
http://ffmpeg.zeranoe.com/builds/#

Thanks Roger!

On Sep 17, 3:11 am, Roger Pack <rogerdp...@gmail.com> wrote:

Roger Pack

unread,
Sep 17, 2011, 11:23:47 AM9/17/11
to roger-p...@googlegroups.com
On Sat, Sep 17, 2011 at 8:19 AM, Dave Horner <daveyd...@gmail.com> wrote:
Yes Mediakit is great.  In fact, the code is very straight forward,
below is a combobox which shows all the video capture devices, it is
bound to the VideoCaptureDevice.  That is enough. :)

So it displays them all in realtime?

 
       <StackPanel>
           <ComboBox x:Name="videoCapDevices"
                                                         ItemsSource="{Binding Source={x:Static
mediakit:MultimediaUtil.VideoInputDevices}}"
                                                         DisplayMemberPath="Name" Margin="0, 2, 0,0" />
           <mediakit:VideoCaptureElement x:Name="vidCap"
EnableSampleGrabbing="True" MinWidth="100" MinHeight="100"
LoadedBehavior="Play"                       DesiredPixelWidth="320"

DesiredPixelHeight="240"
                                              Stretch="Fill"

VideoCaptureDevice="{Binding Path=SelectedItem,
ElementName=videoCapDevices}"
                                              FPS="30"/>
       </StackPanel>
   </Grid>

Yes, I did try the other capture devices and my webcam worked fine.
I'm wondering is this might have to do with format size......it wants
to cap my whole screen at 1920x1200, was gonna try playing with
registry settings.

Yeah there are some helper utilities in there too, but you basically have to change the registry to capture things.
 

As for ffmpeg, I tried the static 64bit build.
http://ffmpeg.zeranoe.com/builds/#


Yeah the release binary is just 32 bit.  Let me know if you "really need" 64 bit and I can start releasing them too...I just never have before so haven't tried to yet.

 
Thanks Roger!
You're welcome.  I'm still embarrassed a bit about the speed of the thing but hopefully with a few iterations it will be faster :P

-r

Dave Horner

unread,
Sep 17, 2011, 11:27:35 PM9/17/11
to roger-projects
> So it displays them all in realtime?
Yes, you select a device from the combo and it displays that device in
realtime.

> Yeah the release binary is just 32 bit.  Let me know if you "really need" 64
> bit and I can start releasing them too...I just never have before so haven't
> tried to yet.
Thanks, that resolved my problems there.

Last time, I think I reported the location of the error wrong....

I now think it is happening because of this line:
var videoStreamConfig = streamConfig as IAMStreamConfig;

in WPFMediaKit\DirectShow\MediaPlayers\VideoCapturePlayer.cs
private bool SetVideoCaptureParameters(ICaptureGraphBuilder2
capGraph, IBaseFilter captureFilter, Guid mediaSubType)
{
/* The stream config interface */
object streamConfig;

/* Get the stream's configuration interface */
int hr = capGraph.FindInterface(PinCategory.Capture,
MediaType.Video,
captureFilter,

typeof(IAMStreamConfig).GUID,
out streamConfig);

DsError.ThrowExceptionForHR(hr);

var videoStreamConfig = streamConfig as IAMStreamConfig;

/* If QueryInterface fails... */
if (videoStreamConfig == null)
{
throw new Exception("Failed to get IAMStreamConfig");
}

Looking your codebase, I see that you are answering for the
IAMStreamConfig interface....
HRESULT CPushPinDesktop::QueryInterface(REFIID riid, void **ppv)
{
// Standard OLE stuff, needed for capture source
if(riid == _uuidof(IAMStreamConfig))
*ppv = (IAMStreamConfig*)this;

hmmm.

--dave

Roger Pack

unread,
Sep 18, 2011, 12:08:17 AM9/18/11
to roger-p...@googlegroups.com
> I now think it is happening because of this line:
>            var videoStreamConfig = streamConfig as IAMStreamConfig;
> ...

> Looking your codebase, I see that you are answering for the
> IAMStreamConfig interface....
> HRESULT CPushPinDesktop::QueryInterface(REFIID riid, void **ppv)
> {
>    // Standard OLE stuff, needed for capture source
>    if(riid == _uuidof(IAMStreamConfig))
>        *ppv = (IAMStreamConfig*)this;
>
> hmmm.


The IAMStreamConfig stuff was somewhat "relic" and now that you
mention it, I might not be registering it right anymore when the DLL
is registered (I...guess that most dshow readers only use its capture
class....maybe [?).
I think I'll pul IAMStreamConfig and send you it to test to see if
that works, as I don't anticipate anybody actually needing/wanting
that anymore anyway...

-r

rogerdpack

unread,
Sep 19, 2011, 2:14:30 PM9/19/11
to roger-projects
What I noticed is that it "used" to show screen-capture-recorder
within graphedit as a Directshow filter.
Now it doesn't, even though I'm registering it the same way as I used
to. So I removed the "double" registration, so see if that would help
(v0.2.4)

I don't have much hope but it's something to try.

Recommend uninstalling all earlier versions, then installing the
latest.

Thanks!
-r

Dave Horner

unread,
Sep 21, 2011, 8:34:50 AM9/21/11
to roger-projects
I'm not sure what you mean by "relic" and pulling IAMStreamConfig.
wpfmedia kit is querying for the IAMStreamConfig interface, your
filter will need to implement this interface to work. right?

I did uninstall and install the latest 0.2.4.1. I am still getting
the IAMSteamConfig failed error.

According to the following link
Exposing Capture and Compression Formats
http://msdn.microsoft.com/en-us/library/dd375630(v=vs.85).aspx
This method can get more information about accepted media types than
the traditional way of enumerating a pin's media types, so it should
typically be used instead.

IAMStreamConfig interface
http://msdn.microsoft.com/en-us/library/dd319784(v=vs.85).aspx

If we are implementing all those methods it should work....

Sorry for the slow reponse.

Thanks Roger.

Roger Pack

unread,
Sep 21, 2011, 7:59:28 PM9/21/11
to roger-p...@googlegroups.com
On Wed, Sep 21, 2011 at 6:34 AM, Dave Horner <daveyd...@gmail.com> wrote:
I'm not sure what you mean by "relic" and pulling IAMStreamConfig.
wpfmedia kit is querying for the IAMStreamConfig interface, your
filter will need to implement this interface to work. right?

Yeah.  I had thought I could remove it but couldn't :) but did cleanup the code a bit.
 

I did uninstall and install the latest 0.2.4.1.  I am still getting
the IAMSteamConfig failed error.

According to the following link
Exposing Capture and Compression Formats
http://msdn.microsoft.com/en-us/library/dd375630(v=vs.85).aspx
This method can get more information about accepted media types than
the traditional way of enumerating a pin's media types, so it should
typically be used instead.


GetStreamCaps is what they typically use, as you said.  But (as you can see in the code), it has a lot in common with IAMStreamConfig.
 

IAMStreamConfig interface
http://msdn.microsoft.com/en-us/library/dd319784(v=vs.85).aspx

If we are implementing all those methods it should work....

It does seem to implement those methods.

I did push a new version but there's nothing big there.  Maybe a 32 versus 64 bit problem?
I uploaded a 64 bit version (wasn't too hard thankfully) so you could experiment with that.
https://sourceforge.net/projects/screencapturer/files
It uses the same name as the other one for now.
Cheers!
-roger-

Dave Horner

unread,
Sep 21, 2011, 8:23:09 PM9/21/11
to roger-p...@googlegroups.com
> I did push a new version but there's nothing big there.  Maybe a 32 versus
> 64 bit problem?
> I uploaded a 64 bit version (wasn't too hard thankfully) so you could
> experiment with that.

Thank you, that solves my ffmpeg 64bit build! :)
But I am still getting the IAMSteamConfig failed error with mediakit.


>> IAMStreamConfig interface
>> http://msdn.microsoft.com/en-us/library/dd319784(v=vs.85).aspx
>>
>> If we are implementing all those methods it should work....
>
> It does seem to implement those methods.

Grr. hhmpf.

Did you get a chance to try the sample on your machine?

Thanks Roger.
--dave

Roger Pack

unread,
Sep 21, 2011, 10:00:12 PM9/21/11
to roger-p...@googlegroups.com


 > Did you get a chance to try the sample on your machine?

Does it work with uscreencapture? i assume I'd have to install visual studio .C#  2010 express?

rogerdpack

unread,
Sep 22, 2011, 12:33:06 PM9/22/11
to roger-projects
I also wonder if it's maybe related to this:
http://ffmpeg.org/pipermail/ffmpeg-devel/2011-September/114825.html
(bottom of the post, enumeration can be "weird")
maybe try removing all other devices and see if that fixes it? Just
to remove that as a possible cause.
Cheers!
-r

renato....@gmail.com

unread,
Feb 24, 2017, 4:02:35 PM2/24/17
to roger-projects
I'm also having the same error trying to get IAMStreamConfig interface under DirectShow.NET with git head from virtual-audio-capture-grabber-device
Did anyone managed to use IAMStreamConfig to change sample rate or number of channels?

Renato
Reply all
Reply to author
Forward
0 new messages