//
// Construimos el grafo de filtros
//
void ConstruirGrafoFiltros(Control controlVideo)
{
try
{
// get the interfaces needed
gb = (IGraphBuilder)new FilterGraph();
mc = (IMediaControl)gb;
me = (IMediaEventEx)gb;
mp = (IMediaPosition)gb;
me.SetNotifyWindow(controlVideo.Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
// creamos el filtro ISampleGrabber y lo configuramos
// usamos este filtro para llevar a cabo las capturas
sb = (ISampleGrabber)new SampleGrabber();
this.ConfigurarSampleGrabber(sb);
gb.AddFilter((IBaseFilter)sb, "SampleGrabber");
// usamos conexion inteligente para el resto
gb.RenderFile(nomFic, null);
// establecemos algunas propiedades del video
bv = (IBasicVideo)gb;
bv.GetVideoSize(out ancVid, out altVid);
this.Propietario(controlVideo);
this.ObtenerStride();
// run arrancamos el grafo
mc.Run();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
//
// configuracion del SampleGrabber
//
void ConfigurarSampleGrabber(ISampleGrabber sampGrabber)
{
AMMediaType media;
// establecemos caracteristicas del flujo
media = new AMMediaType();
media.majorType = MediaType.Video;
media.subType = MediaSubType.RGB24;
media.formatType = FormatType.VideoInfo;
//media.formatType = FormatType.VideoInfo2;
//media.formatType = FormatType.MpegVideo;
//media.formatType = FormatType.Mpeg2Video;
//FormatType.DvInfo
// asociamos caracteristicas a filtro
sb.SetMediaType(media);
DsUtils.FreeAMMediaType(media);
media = null;
// llamamos a BufferCB
sb.SetCallback(this, 1);
}