Question

object vdeosource;
DsDevice device1 = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)[1];
Guid baseIdentifier = typeof(IBaseFilter).GUID;
device1.Mon.BindToObject(null, null, ref baseIdentifier, out vdeosource);
IBaseFilter sourceFilter = vdeosource as IBaseFilter;
graphBuilder.AddFilter(sourceFilter, "Source");

hr = captureGraphBuilder.SetFiltergraph(this.graphBuilder);
DsError.ThrowExceptionForHR(hr);

mpeg2Demux = (IBaseFilter)new MPEG2Demultiplexer();

object cross;
captureGraphBuilder.FindInterface(FindDirection.UpstreamOnly, null, sourceFilter, typeof(IAMCrossbar).GUID, out cross);
IAMCrossbar crossbar2 = cross as IAMCrossbar;
int inputpincount, outputpincount;
crossbar2.get_PinCounts(out outputpincount, out inputpincount);
crossbar2.Route(0, 0);

If I try to render video at this point, I get some 5sec delayed pictures from my playing video which is connected as input for my capture card. My capture card output is mpeg2.

IBaseFilter demuxFilter = (IBaseFilter)new MPEG2Demultiplexer();
graphBuilder.AddFilter(demuxFilter, "Mpeg-2 Demultiplexor");

IPin sourceFilterOutputPin = DsFindPin.ByDirection(sourceFilter, PinDirection.Output, 0);
IPin demuxFilterPinIn = DsFindPin.ByDirection(demuxFilter, PinDirection.Input, 0);

hr = graphBuilder.Connect(sourceFilterOutputPin, demuxFilterPinIn);
DsError.ThrowExceptionForHR(hr);

IBaseFilter defaultRenderer = (IBaseFilter)new VideoRendererDefault();
hr = graphBuilder.AddFilter(defaultRenderer, "Default Renderer");
DsError.ThrowExceptionForHR(hr);

hr = captureGraphBuilder.RenderStream(null, MediaType.Video, sourceFilter, null, defaultRenderer);
DsError.ThrowExceptionForHR(hr);

At this point I get an error which says there is no combination of intermediate filters... All I wanna know is whether I am using mpeg2 demux right or wrong?

Was it helpful?

Solution

You shouldn't need to connect the source to the demux before rendering the stream. This may be confusing the render operation.

During rendering operations, DirectShow will try to the use the filters already present in the graph before trying other registered filters so you can add your preferred filters to the graph without connecting them.

You may also be missing appropriate mpeg2 decoding or color space conversion filters. Have you simulated any of this with a graph editing tool (e.g. Graph Studio Next or GraphEdit in the Windows SDK)?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top