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;
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 ?