Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5997983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:20:29+00:00 2026-05-23T00:20:29+00:00

currently I have a disfigured avi file that a program of mine creates. I

  • 0

currently I have a disfigured avi file that a program of mine creates. I found out that by going into graphedit, i can refigure it correctly.

I found that if i do:

SourceFile(test1.avi) -> AVI Splitter -> ffdshow video encoder -> AVI Mux -> File Writer

i can get a video stream back that is correct.

Now I am trying to convert this into C# Directshow.Net program that i can just call.

I create a graph and i add in a SourceFilter from the video file i want converted, i add in a grabber, find and then add the ffdshow encoder, AVI Mux and then setOutputFileName().

{
        filename = textBox1.Text;
        IFilterGraph2 filter = new FilterGraph() as IFilterGraph2;
        ICaptureGraphBuilder2 MainGraph = new CaptureGraphBuilder2() as ICaptureGraphBuilder2;
        int result;
        result = MainGraph.SetFiltergraph(filter);

        IBaseFilter source;
        result = filter.AddSourceFilter(filename, filename, out source);

        ISampleGrabber samplegrabber = (ISampleGrabber)new SampleGrabber();
        IBaseFilter basegrab = (IBaseFilter)samplegrabber;

        AMMediaType media;
        media = new AMMediaType();
        media.majorType = MediaType.Video;
        media.subType = MediaSubType.RGB32;
        media.formatType = FormatType.VideoInfo;
        result = samplegrabber.SetMediaType(media);

        DsUtils.FreeAMMediaType(media);
        result = samplegrabber.SetBufferSamples(true);

        result = filter.AddFilter(basegrab, "filter");

        //MainGraph.RenderStream(null, null, source, basegrab, null);



        IMediaEvent mediaEvent;
        IMediaControl mediacontrol;
        mediaEvent = filter as IMediaEvent;
        mediacontrol = filter as IMediaControl;






        IntPtr hEvent;
        result = mediaEvent.GetEventHandle(out hEvent);

        ManualResetEvent mre;

        mre = new ManualResetEvent(false);
        mre.SafeWaitHandle = new Microsoft.Win32.SafeHandles.SafeWaitHandle(hEvent, true);

        //Thread t = new Thread(new ThreadStart(this.EventWait));

        //mediacontrol.Run();

        object newsource = null;
        IBaseFilter encoder;

        Guid iid = typeof(IBaseFilter).GUID;
        foreach (DsDevice device in DsDevice.GetDevicesOfCat(FilterCategory.VideoCompressorCategory))
        {
            if (device.Name.CompareTo("ffdshow video encoder") == 0)
            {
                device.Mon.BindToObject(null, null, ref iid, out newsource);
                break;
            }
        }

        encoder = (IBaseFilter)newsource;
object newsource2 = null;
        IBaseFilter encoder2;

        Guid iid2 = typeof(IBaseFilter).GUID;
        foreach (DsDevice device in DsDevice.GetDevicesOfCat(FilterCategory.LegacyAmFilterCategory))
        {
            if (device.Name.CompareTo("AVI Mux") == 0)
            {
                device.Mon.BindToObject(null, null, ref iid2, out newsource2);
                break;
            }
        }

        encoder2 = (IBaseFilter)newsource2;
        result = filter.AddFilter(encoder, "encoder");
        result = filter.AddFilter(encoder2, "Avi Mux");


        FileWriter file = new FileWriter();
        IFileSinkFilter fs = (IFileSinkFilter)file;
        IBaseFilter mux;
        IFileSinkFilter sink;
        Guid cat;
        Guid med;
  cat = PinCategory.Capture;
        med = MediaType.Video;


        //result = filter.AddFilter(encoder, "encoder");
        result = MainGraph.SetOutputFileName(MediaSubType.Avi, "C:\\Users\\Caleb\\Desktop\\conversion.avi", out mux, out sink);

        result = MainGraph.RenderStream( cat,  med, source, null, mux);
mediacontrol.Run();

}

this code creates the same graph to my knowledge. It creates my file, but doesnt convert anything. The file it creates is 0bytes. Am i doing renderstream wrong or some other error in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:20:29+00:00Added an answer on May 23, 2026 at 12:20 am

    i put in a piece of code:

    DsRotEntry m_rot = new DsRotEntry(filter);
    

    this allowed me to view my filter i made, in graphedit.

    what happened was i add the filters but none of them got connected to each other.

    So then what i did was got each of the filters i added, found the input and output pins associated with them

    Filter2.FindPin( "name of the input pin here", out pinName);
    Filter1.FindPin( "name of the output pin here", out PinName2);
    
    MainFilter.connect( PinName2, pinName);
    

    this created a connection between the filters. I wasnt doing this and i did this and now im getting closer to what i want.

    so basically for Directshow.net and DirectShowNet-Lib it programs like

    find a filter -> add a filter -> find a filter -> add a filter -> find the pins -> connect the pins -> run
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a sql statement that outputs data into an excel document. However,
We currently have an application that sends out SMS to users, it acts like
We currently have a block list for Lync 2010 that contains all file extensions
Currently have a drop down menu that is activated on a hover (from display:none
I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty
I currently have one project that currently contains multiple packages. These packages make up
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
I currently have a tab bar application in the works, and have run into
I currently have: Range(Z1).Interior.Color = RGB(255, 255, 255) But this wipes out the borders
I currently have a closure table used for hierarchical data that has 5 million

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.