Reputation: 1885
I have been detect the audio and video devices and build the Capture Graph, but in the last filter I cannot render both of them.
DsDevice dev = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)[0];
hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out capFilter);
Marshal.ThrowExceptionForHR( hr );
DsDevice audioDv = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice)[0];
hr = m_FilterGraph.AddSourceFilterForMoniker(audioDv.Mon, null, audioDv.Name, out audioFilter);
Marshal.ThrowExceptionForHR(hr);
asfWriter = ConfigAsf(capGraph, szOutputFileName);
hr = capGraph.RenderStream(null, MediaType.Audio, audioFilter, null, asfWriter);
Marshal.ThrowExceptionForHR(hr);
hr = capGraph.RenderStream(null, MediaType.Video, capFilter, null, asfWriter);
Marshal.ThrowExceptionForHR( hr );
This is a piece of code that I try, Should I choose the other MediaType?
Upvotes: 0
Views: 1636
Reputation:
I'm a C++ directshow developer, I'm not familiar with DirectShow.net, so I can't comment on your code.
But I have lots of DShow experience...
To write video and audio media streams to a file, you need a mux filter.
From your source filter(s), both video and audio pins should connect to a mux (short for multiplexer) filter. From there, the (single pin) output of the mux filter will connect to the File Writer filter.
Mux filters are dependent on the media types in use. That you can't connect both streams to your mux filter would suggest that it doesn't support one (or both) of the media types.
In that case, do a couple of tests - e.g. render only the video stream to disk, and then render only audio disk. At least one of them won't work - that's the offending media type.
You could try googling for an alternative mux filter, write your own, or, change the media type of your source stream.
Hope this is of at least some help!
Upvotes: 2