Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Now,I've recorded the videos .But when I play it with Media Player ,it goes so fast !
I want to control it with IMediaPostion or IMediaSeeking ,but seems I don't get the right way .
Here ,the codes:
DsDevice[] audios;
            DsDevice[] videos;
            audios = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice);
            videos = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
            ICaptureGraphBuilder2 theCapBuilder = null;
            IBaseFilter capFilter = null;
            IBaseFilter audFilter=null;
            IBaseFilter asfWriter = null;
            IMediaControl theControl = null;
            IMediaSeeking theSeeking = null;
            IMediaPosition thePosition = null;
            IVideoWindow theWindow = null;
            IAMStreamConfig AMConfig = null;

            IFilterGraph2 theFilterGraph = null;
            theCapBuilder = new CaptureGraphBuilder2() as ICaptureGraphBuilder2;
            theFilterGraph = new FilterGraph() as IFilterGraph2;
            theCapBuilder.SetFiltergraph(theFilterGraph);
            theFilterGraph .AddSourceFilterForMoniker (videos[0].Mon ,null,videos [0].Name ,out capFilter );
            theFilterGraph .AddSourceFilterForMoniker (audios[0].Mon ,null ,audios [0].Name ,out audFilter);
            IFileSinkFilter pTmpSink = null;
            
            
            SaveFileDialog theDlg = new SaveFileDialog();
            theDlg.ShowDialog();
            
            string szOutputFileName = theDlg.FileName;

            int hr =theCapBuilder .SetOutputFileName(MediaSubType.Asf  , szOutputFileName, out asfWriter, out pTmpSink);
            IConfigAsfWriter theConfig = asfWriter as IConfigAsfWriter;
            
            Guid theGuid = new Guid(0x6E2A6955, 0x81DF, 0x4943, 0xBA, 0x50, 0x68, 0xA9, 0x86, 0xA7, 0x08, 0xF6);
            theConfig.ConfigureFilterUsingProfileGuid(theGuid );
            theCapBuilder.RenderStream(null, null, capFilter, null, asfWriter);
            theCapBuilder.RenderStream(null, null, audFilter, null, asfWriter);
            theSeeking = theFilterGraph as IMediaSeeking;
            thePosition =theFilterGraph as IMediaPosition;
            theWindow = theFilterGraph as IVideoWindow;

            //Here ,all theSeeking and thePostion don't help 
            theSeeking.SetTimeFormat(TimeFormat .Sample  );
            theSeeking.SetRate(1);
            thePosition.put_Rate(1);
           
            theWindow.put_Owner( this.Handle);
            theWindow.put_Visible(OABool.True);
            theWindow.put_WindowState(DirectShowLib.WindowState.Show);
            theWindow.SetWindowPosition(0, 0, 100, 200);
            
            theWindow.put_WindowStyle(WindowStyle.Child|WindowStyle .ClipChildren );
            
          
            
            theControl = theFilterGraph as IMediaControl;
            
            theControl.Run();
            this.Text =audios [0].Name ; 

I've had a try with IAMStreamConfig ,but didn't find the interface ..
AND,here is a another question :
Guid theGuid = new Guid(0x6E2A6955, 0x81DF, 0x4943, 0xBA, 0x50, 0x68, 0xA9, 0x86, 0xA7, 0x08, 0xF6);
            theConfig.ConfigureFilterUsingProfileGuid(theGuid );


What is the GUID if I want to record to AVI ?
Posted
Updated 7-Jun-10 20:24pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900