为纹理指定的格式无效

时间:2013-03-31 17:48:55

标签: directshow video-capture bootcamp

我想使用我的macbook的*内置iSight“相机(我在训练营中)。

我创建了一个简单的程序,使用 DirectShow 图表从网络摄像头读取视频流。这是* Form1_Load()*方法:

private void Form1_Load(object sender, EventArgs e)
{
    int hr = 0;

    _graphBuilder = (IGraphBuilder)new FilterGraph();
    Console.WriteLine("Create the VMR9 object");

    _vmr9 = (IBaseFilter)new VideoMixingRenderer9();

    Console.WriteLine("Configure the VMR9 for one stream");
    _filterConfig = (IVMRFilterConfig9)_vmr9;
    // One stream is enough for this sample
    _filterConfig.SetNumberOfStreams(1);

    _graphBuilder.AddFilter(_vmr9, "Video Mixing Renderer");


    Console.WriteLine("Change VMR9 mode to Windowless");
    hr = _filterConfig.SetRenderingMode(VMR9Mode.Windowless);
    Marshal.ThrowExceptionForHR(hr);

    _windowlessCtrl = (IVMRWindowlessControl9)_vmr9;

    Console.WriteLine("Set parent window");
    hr = _windowlessCtrl.SetVideoClippingWindow(this.Handle);
    Marshal.ThrowExceptionForHR(hr);

    Console.WriteLine("Set Aspect-Ratio");
    hr = _windowlessCtrl.SetAspectRatioMode(VMR9AspectRatioMode.None);
    Marshal.ThrowExceptionForHR(hr);

    Console.WriteLine("Set video position");
    hr = _windowlessCtrl.SetVideoPosition(null, DsRect.FromRectangle(this.ClientRectangle));
    Marshal.ThrowExceptionForHR(hr);

    Console.WriteLine("Building graph...");

    ICaptureGraphBuilder2 pBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
    hr = pBuilder.SetFiltergraph(_graphBuilder);
    checkHR(hr, "Can't SetFiltergraph");

    Guid CLSID_WDMStreamingCaptureDevices = new Guid("{65E8773D-8F56-11D0-A3B9-00A0C9223196}"); //

    //add Built-in iSight
    IBaseFilter pBuiltiniSight = CreateFilterByName(@"Built-in iSight", CLSID_WDMStreamingCaptureDevices);
    hr = _graphBuilder.AddFilter(pBuiltiniSight, "Built-in iSight");
    checkHR(hr, "Can't add Built-in iSight to graph");

    //connect Built-in iSight and Video Renderer
    hr = _graphBuilder.ConnectDirect(GetPin(pBuiltiniSight, "Capturer"), GetPin(_vmr9, "VMR Input0"), null); // => Program hungs up!!!
    checkHR(hr, "Can't connect Built-in iSight and Video Renderer");

    Console.WriteLine("Running...");
    mediaControl = (IMediaControl)_graphBuilder;
    hr = mediaControl.Run();
    checkHR(hr, "Can't run the graph");
}

调用 ConnectDirect()方法时程序卡住了......

用于工作。使用视频渲染器过滤器时,它完全正常,但我需要使用视频混合渲染器9。

我使用 TraceSpy 来捕捉以下内容:

Direct3D9: :====> ENTER: DLLMAIN(581fd9a0): Process Attach: 00000a70, tid=00000658
Direct3D9: :====> EXIT: DLLMAIN(581fd9a0): Process Attach: 00000a70
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO
Direct3D9: (INFO) :======================= Hal SWVP device selected
Direct3D9: (INFO) :HalDevice Driver Style b
Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :Using FF to PS converter
Direct3D9: (INFO) :Enabling multi-processor optimizations
Direct3D9: (WARN) :Athlon32Compiler: CPU does not meet minimum requirements
Direct3D9: (INFO) :Using P4 PSGP
Direct3D9: (INFO) :Using FF to VS converter in software vertex processing
Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode
Direct3D9: :DoneExclusiveMode
Direct3D9: (ERROR) :Invalid format specified for texture

0 个答案:

没有答案