Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Trouble creating my first graph

  • hi all, this is first time i try to create a directshow graph and can't understand why it not words. Here the code where i catch and exception "pointer not valid" on
    hr = m_FilterGraph.Connect(iPinPlexOutput, iPinDecoderInput); row.
    Thanks for your support on solve this problem, here it is the code :

    int hr;
    IBaseFilter ibfRenderer = null;
    ISampleGrabber sampGrabber = null;
    //IBaseFilter capFilter = null;
    IPin iPinInFilter = null;
    IPin iPinOutFilter = null;
    IPin iPinInDest = null;
    Type type = null;
    IEnumPins pinEnum;

    // Get the graphbuilder object
    m_FilterGraph = new FilterGraph() as IFilterGraph2;

    // *********
    IBaseFilter sourceFilter;
    hr = m_FilterGraph.AddSourceFilter(FileName, FileName, out sourceFilter);
    IPin iPinSourceFilterOut = DsFindPin.ByDirection(sourceFilter, PinDirection.Output, 0);

    // *********
    type = Type.GetTypeFromCLSID(new Guid("{AFB6C280-2C41-11D3-8A60-0000F81E0E4A}"));
    IBaseFilter filterPlex = (IBaseFilter)Activator.CreateInstance(type);
    hr = m_FilterGraph.AddFilter(filterPlex, "MPEG-2 Demultiplexer");

    IPin iPinPlexInput = DsFindPin.ByDirection((IBaseFilter)filterPlex, PinDirection.Input, 0);
    IPin iPinPlexOutput = DsFindPin.ByDirection((IBaseFilter)filterPlex, PinDirection.Output, 1);// Tried 0, 1 but nothing change
    // Connect Pin
    hr = m_FilterGraph.Connect(iPinSourceFilterOut, iPinPlexInput); // Tried even m_FilterGraph.ConnectDirect...

    // *********
    type = Type.GetTypeFromCLSID(new Guid("{37A4D808-E76C-11D2-935C-00A024E52661}"));
    IBaseFilter filterDecoder = (IBaseFilter)Activator.CreateInstance(type);
    hr = m_FilterGraph.AddFilter(filterDecoder, "ATI MPEG Video Decoder");

    IPin iPinDecoderInput = DsFindPin.ByDirection((IBaseFilter)filterDecoder, PinDirection.Input, 0);
    IPin iPinDecoderOutput = DsFindPin.ByDirection((IBaseFilter)filterDecoder, PinDirection.Output, 0);
    // Connect Pin
    hr = m_FilterGraph.Connect(iPinPlexOutput, iPinDecoderInput); <---- HERE THROW EXCEPTION

    // *********
    type = Type.GetTypeFromCLSID(new Guid("{B87BEB7B-8D29-423F-AE4D-6582C10175AC}"));
    IBaseFilter filterVideoRenderer = (IBaseFilter)Activator.CreateInstance(type);
    hr = m_FilterGraph.AddFilter(filterVideoRenderer, "Video Renderer");

    IPin iPinVideoRendererIn = DsFindPin.ByDirection(filterVideoRenderer, PinDirection.Input, 0);
    hr = m_FilterGraph.Connect(iPinDecoderOutput, iPinVideoRendererIn);

  • snarfle

    My first guess is that one of m_FilterGraph, iPinPlexOutput, or iPinDecoderInput is NULL.

  • Mariam Louis
    Mariam Louis

    I have a problem when press on record button in DX Tuner Sample somwtimes video is displayed but without motion as image & sometimes screen continue black & sometimes working properly but the problem happen at first record press

    Please Help urgently