2011-09-12 28 views
5

के साथ काम करने के लिए IAMStreamConfig.SetFormat() को नहीं बना सकता मैं डायरेक्टशो में नया हूं और अपने एप्लिकेशन में एक वीडियो स्ट्रीम जोड़ने पर काम कर रहा हूं। मैंने वहां कई समाधानों को देखा है (टचलेस, डायरेक्टशो.net, इत्यादि) और इस small project on Code Project के साथ जा रहा है इसके लिए बहुत कुछ नहीं है, इसलिए मैंने इसे चुना है; मैं एक छोटे कोड बेस के साथ काम करना चाहता था, क्योंकि मुझे यह सुविधा जल्दी से लागू करने की आवश्यकता है।लाइफकैम स्टूडियो

पढ़ने, प्रयोग करने और डिबगिंग के ठोस दिन के बाद अंत में सबकुछ अच्छी तरह से काम कर रहा है। एक देरी है जो एक बमर है लेकिन मैं इसके बारे में बाद में चिंता कर सकता हूं। इस बिंदु पर मेरे पास यह मुद्दा है कि the camera is capable of 1280X720 और मैं इस समाधान का उपयोग करना चाहता हूं। हालांकि यह 640x480 पर कब्जा करने के लिए निर्धारित लगता है। जैसे ही मैंने संकल्प को सेट करने के लिए गहरी और गहरी और गहरी सीख डाली, मैंने अंततः सोचा कि मुझे यह पता चला है। मुझे उस कोड प्रोजेक्ट पेज पर उन टिप्पणियों में कोड भी मिला जो मैंने आधार के रूप में उपयोग किया था।

कोशिश करने के 6 घंटे बाद, मैं इस कैमरे को अपने संकल्प को बदलने के लिए नहीं प्राप्त कर सकता। मुझे कोई त्रुटि नहीं मिल रही है और SetFormat() से वापस HRESULT 0 है, फिर भी कैमरा संकल्प को नहीं बदलेगा।

सब कुछ पेस्ट करने के लिए बहुत अधिक कोड है, लेकिन मैं उस अनुभाग को शामिल करना चाहता हूं जो ग्राफ को बनाता है क्योंकि मुझे कल्पना है कि समस्या कहां है।

यहाँ कोड है कि ग्राफ सेट करता है

void CameraMethods::StartCamera(int camIndex, interior_ptr<int> width, 
    interior_ptr<int> height) 
{ 
    if (g_pGraphBuilder != NULL) 
     throw gcnew ArgumentException("Graph Builder was null"); 

    IMoniker *pMoniker = GetMoniker(camIndex); 
    pMoniker->AddRef(); 

    HRESULT hr = S_OK; 

    // Build all the necessary interfaces to start the capture 
    if (SUCCEEDED(hr)) 
    { 
     hr = CoCreateInstance(CLSID_FilterGraph, 
      NULL, 
      CLSCTX_INPROC, 
      IID_IGraphBuilder, 
      (LPVOID*)&g_pGraphBuilder); 
    } 

    if (SUCCEEDED(hr)) 
     hr = g_pGraphBuilder->QueryInterface(IID_IMediaControl, (LPVOID*)&g_pMediaControl); 

    if (SUCCEEDED(hr)) 
    { 
     hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, 
      NULL, 
      CLSCTX_INPROC, 
      IID_ICaptureGraphBuilder2, 
      (LPVOID*)&g_pCaptureGraphBuilder); 
    } 

    // Setup the filter graph 
    if (SUCCEEDED(hr)) 
     hr = g_pCaptureGraphBuilder->SetFiltergraph(g_pGraphBuilder); 

    // Build the camera from the moniker 
    if (SUCCEEDED(hr)) 
     hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (LPVOID*)&g_pIBaseFilterCam); 

    // Add the camera to the filter graph 
    if (SUCCEEDED(hr)) 
     hr = g_pGraphBuilder->AddFilter(g_pIBaseFilterCam, L"WebCam"); 

    // Create a SampleGrabber 
    if (SUCCEEDED(hr)) 
     hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, 
      (void**)&g_pIBaseFilterSampleGrabber); 

    // Configure the Sample Grabber 
    if (SUCCEEDED(hr)) 
     hr = ConfigureSampleGrabber(g_pIBaseFilterSampleGrabber); 

    // Set the resolution - I have NO idea where this should be executed 
    SetCaptureFormat(camIndex, *width, *height); 

    // Add Sample Grabber to the filter graph 
    if (SUCCEEDED(hr)) 
     hr = g_pGraphBuilder->AddFilter(g_pIBaseFilterSampleGrabber, L"SampleGrabber"); 

    // Create the NullRender 
    if (SUCCEEDED(hr)) 
     hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, 
      (void**)&g_pIBaseFilterNullRenderer); 

    // Add the Null Render to the filter graph 
    if (SUCCEEDED(hr)) 
     hr = g_pGraphBuilder->AddFilter(g_pIBaseFilterNullRenderer, L"NullRenderer"); 

    // Configure the render stream 
    if (SUCCEEDED(hr)) 
     hr = g_pCaptureGraphBuilder->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, 
      g_pIBaseFilterCam, g_pIBaseFilterSampleGrabber, g_pIBaseFilterNullRenderer); 

    // Grab the capture width and height 
    if (SUCCEEDED(hr)) 
    { 
     ISampleGrabber* pGrabber = NULL; 
     hr = g_pIBaseFilterSampleGrabber->QueryInterface(IID_ISampleGrabber, (LPVOID*)&pGrabber); 
     if (SUCCEEDED(hr)) 
     { 
      AM_MEDIA_TYPE mt; 
      hr = pGrabber->GetConnectedMediaType(&mt); 
      if (SUCCEEDED(hr)) 
      { 
       VIDEOINFOHEADER *pVih; 
       if ((mt.formattype == FORMAT_VideoInfo) && 
        (mt.cbFormat >= sizeof(VIDEOINFOHEADER)) && 
        (mt.pbFormat != NULL)) 
       { 
        pVih = (VIDEOINFOHEADER*)mt.pbFormat; 
        *width = pVih->bmiHeader.biWidth; 
        *height = pVih->bmiHeader.biHeight; 
       } 
       else 
       { 
        hr = E_FAIL; // Wrong format 
       } 

       // FreeMediaType(mt); (from MSDN) 
       if (mt.cbFormat != 0) 
       { 
        CoTaskMemFree((PVOID)mt.pbFormat); 
        mt.cbFormat = 0; 
        mt.pbFormat = NULL; 
       } 
       if (mt.pUnk != NULL) 
       { 
        // Unecessary because pUnk should not be used, but safest. 
        mt.pUnk->Release(); 
        mt.pUnk = NULL; 
       } 
      } 
     } 

     if (pGrabber != NULL) 
     { 
      pGrabber->Release(); 
      pGrabber = NULL; 
     } 
    } 

    // Start the capture 
    if (SUCCEEDED(hr)) 
     hr = g_pMediaControl->Run(); 

    // If init fails then ensure that you cleanup 
    if (FAILED(hr)) 
     StopCamera(); 
    else 
     hr = S_OK; // Make sure we return S_OK for success 

    // Cleanup 
    if (pMoniker != NULL) 
    { 
     pMoniker->Release(); 
     pMoniker = NULL; 
    } 

    if (SUCCEEDED(hr)) 
     this->activeCameraIndex = camIndex; 
    else 
     throw gcnew COMException("Error Starting Camera", hr); 
} 

[अद्यतन] जोड़े ConfigureSampleGrabber() नीचे

HRESULT CameraMethods::ConfigureSampleGrabber(IBaseFilter *pIBaseFilter) 
{ 
    HRESULT hr = S_OK; 
    ISampleGrabber *pGrabber = NULL; 

    hr = pIBaseFilter->QueryInterface(IID_ISampleGrabber, (void**)&pGrabber); 
    if (SUCCEEDED(hr)) 
    { 
     AM_MEDIA_TYPE mt; 
     ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE)); 
     mt.majortype = MEDIATYPE_Video; 
     mt.subtype = MEDIASUBTYPE_RGB24; 
     mt.formattype = FORMAT_VideoInfo; 
     hr = pGrabber->SetMediaType(&mt); 
    } 

    if (SUCCEEDED(hr)) 
     hr = pGrabber->SetCallback(new SampleGrabberCB(), 1); 

    if (pGrabber != NULL) 
    { 
     pGrabber->Release(); 
     pGrabber = NULL; 
    } 

    return hr; 
} 

विधि काफी CodeProject स्रोत से सटीक कोड है कोड।

void CameraMethods::SetCaptureFormat(int camIndex, int width, int height) 
{ 
    HRESULT hr = S_OK; 
    IMoniker* pMoniker = GetMoniker(camIndex); 

    IBaseFilter* pCap; 
    hr=pMoniker->BindToObject(0,0,IID_IBaseFilter,(void **)&pCap); 

    if(!SUCCEEDED(hr)) 
     return; 

    IAMStreamConfig *pConfig = NULL; 

    if(g_pCaptureGraphBuilder == NULL) // no CaptureGraphBuilder initialised 
     return; 

    hr = g_pCaptureGraphBuilder->FindInterface(
     &PIN_CATEGORY_CAPTURE, // Preview pin. 
     0, // Any media type. 
     pCap, // Pointer to the capture filter. 
     IID_IAMStreamConfig, (void**)&pConfig); 

    if(!SUCCEEDED(hr)) 
     return; 

    int iCount = 0, iSize = 0; 
    hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize); 

    // Check the size to make sure we pass in the correct structure. 
    if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) { 

     // Use the video capabilities structure. 
     for (int iFormat = 0; iFormat < iCount; iFormat++) 
     { 
      VIDEO_STREAM_CONFIG_CAPS scc; 
      AM_MEDIA_TYPE *pmt; 
      /* Note: Use of the VIDEO_STREAM_CONFIG_CAPS structure to configure a video device is 
      deprecated. Although the caller must allocate the buffer, it should ignore the 
      contents after the method returns. The capture device will return its supported 
      formats through the pmt parameter. */ 
      hr = pConfig->GetStreamCaps(iFormat, &pmt, (BYTE*)&scc); 
      if (SUCCEEDED(hr)) 
      { 
       /* Examine the format, and possibly use it. */ 
       if (pmt->formattype == FORMAT_VideoInfo) { 
        // Check the buffer size. 
        if (pmt->cbFormat >= sizeof(VIDEOINFOHEADER)) 
        { 
         VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat); 
         BITMAPINFOHEADER *bmiHeader = &pVih->bmiHeader; 

         /* Access VIDEOINFOHEADER members through pVih. */ 
         if(bmiHeader->biWidth == width && bmiHeader->biHeight == height && 
          bmiHeader->biBitCount == 24) 
         { 
          hr = pConfig->SetFormat(pmt); 
         } 
        } 
       } 

       // Delete the media type when you are done. 
       DeleteMediaType(pmt); 
      } 
     } 
    } 
} 

मुझे लगता है कि SetFormat करने के लिए कॉल() निष्पादित किया जाता है कोड के माध्यम से कदम रखा और सत्यापित करने के बाद और एक मान्य HRESULT वापसी: मैं तो संकल्प स्थापित करने के लिए इस विधि गयी। हालांकि कब्जे वाले फ्रेम में कोई बदलाव नहीं है।

कोई त्रुटि संदेश नहीं है यह जानना मुश्किल है कि कहां से शुरू करना है। मुझे आशा है कि यहां कुछ डायरेक्टशो विशेषज्ञ हैं जो समस्या को देखेंगे, मैं भी एक अच्छा ओल 'फैशन संवेदना से खुश रहूंगा "ठीक है, आप कैमरे को फ्रेम आकार बदलने के लिए कैसे उम्मीद करते हैं जब बफर आवंटित किया जाता है फिल्टर स्टैक और विजेट को foobar में शुरू किया गया है! पीएफटी ... lol ";)

मुझे सिखाओ, ओह डायरेक्टशो/कॉम भगवान!

[अद्यतन # 2]

प्रति रोमन के सुझाव मैं करने के लिए GraphStudio का इस्तेमाल किया है (FYI करें, यह अजीब है कि हम सिर्फ इस प्रणाली के लिए एक नया संदेश नहीं जोड़ सकते हैं और इस तरह से मूल संपादित करने की जरूरत है) मेरे ग्राफ के हुड के नीचे देखो। मैं स्वीकार करूंगा कि मैं अभी भी समझ में नहीं आता कि मैं वास्तव में क्या देख रहा हूं। मुझे एक "टेक्स्ट रिपोर्ट" फ़ंक्शन मिला और सोचा कि यह रिपोर्ट यहां पोस्ट करने में सहायक होगी यदि यह कुछ मूल्यवान जानकारी दिखाती है।

-------------------------------------------------- 
    Filters 
-------------------------------------------------- 
    1. Smart Tee 
    2. MJPEG Decompressor 
    3. SampleGrabber 
    4. NullRenderer 
    5. WebCam 

-------------------------------------------------- 
    Connections 
-------------------------------------------------- 
    1. [Smart Tee]/(Capture) -> [MJPEG Decompressor]/(XForm In) 
     Major: MEDIATYPE_Video 
     Subtype: MEDIASUBTYPE_MJPG 
      bFixedSizeSamples: TRUE 
      bTemporalCompression: FALSE 
      lSampleSize:   921600 
      cbFormat:    88 
     Format: FORMAT_VideoInfo 
     VIDEOINFOHEADER: 
      rcSource:    (0,0,0,0) 
      rcTarget:    (0,0,0,0) 
      dwBitRate:   221184000 
      dwBitErrorRate:  0 
      AvgTimePerFrame:  333333 
     BITMAPINFOHEADER: 
      biSize:    40 
      biWidth:    640 
      biHeight:    480 
      biPlanes:    1 
      biBitCount:   24 
      biCompression:  0x47504A4D 
      biSizeImage:   921600 
      biXPelsPerMeter:  0 
      biYPelsPerMeter:  0 
      biClrUsed:   0 
      biClrImportant:  0 

    2. [MJPEG Decompressor]/(XForm Out) -> [SampleGrabber]/(Input) 
     Major: MEDIATYPE_Video 
     Subtype: MEDIASUBTYPE_RGB24 
      bFixedSizeSamples: TRUE 
      bTemporalCompression: FALSE 
      lSampleSize:   921600 
      cbFormat:    88 
     Format: FORMAT_VideoInfo 
     VIDEOINFOHEADER: 
      rcSource:    (0,0,0,0) 
      rcTarget:    (0,0,0,0) 
      dwBitRate:   221184221 
      dwBitErrorRate:  0 
      AvgTimePerFrame:  333333 
     BITMAPINFOHEADER: 
      biSize:    40 
      biWidth:    640 
      biHeight:    480 
      biPlanes:    1 
      biBitCount:   24 
      biCompression:  0x00000000 
      biSizeImage:   921600 
      biXPelsPerMeter:  0 
      biYPelsPerMeter:  0 
      biClrUsed:   0 
      biClrImportant:  0 

    3. [SampleGrabber]/(Output) -> [NullRenderer]/(In) 
     Major: MEDIATYPE_Video 
     Subtype: MEDIASUBTYPE_RGB24 
      bFixedSizeSamples: TRUE 
      bTemporalCompression: FALSE 
      lSampleSize:   921600 
      cbFormat:    88 
     Format: FORMAT_VideoInfo 
     VIDEOINFOHEADER: 
      rcSource:    (0,0,0,0) 
      rcTarget:    (0,0,0,0) 
      dwBitRate:   221184221 
      dwBitErrorRate:  0 
      AvgTimePerFrame:  333333 
     BITMAPINFOHEADER: 
      biSize:    40 
      biWidth:    640 
      biHeight:    480 
      biPlanes:    1 
      biBitCount:   24 
      biCompression:  0x00000000 
      biSizeImage:   921600 
      biXPelsPerMeter:  0 
      biYPelsPerMeter:  0 
      biClrUsed:   0 
      biClrImportant:  0 

    4. [WebCam]/(Capture) -> [Smart Tee]/(Input) 
     Major: MEDIATYPE_Video 
     Subtype: MEDIASUBTYPE_MJPG 
      bFixedSizeSamples: TRUE 
      bTemporalCompression: FALSE 
      lSampleSize:   921600 
      cbFormat:    88 
     Format: FORMAT_VideoInfo 
     VIDEOINFOHEADER: 
      rcSource:    (0,0,0,0) 
      rcTarget:    (0,0,0,0) 
      dwBitRate:   221184000 
      dwBitErrorRate:  0 
      AvgTimePerFrame:  333333 
     BITMAPINFOHEADER: 
      biSize:    40 
      biWidth:    640 
      biHeight:    480 
      biPlanes:    1 
      biBitCount:   24 
      biCompression:  0x47504A4D 
      biSizeImage:   921600 
      biXPelsPerMeter:  0 
      biYPelsPerMeter:  0 
      biClrUsed:   0 
      biClrImportant:  0 

[अद्यतन # 3] - पवित्र गाय, मैंने क्या शुरू किया है ?! मैं came across something that supports रोमन के विस्मृत रंगों के सिद्धांत से पहले कभी गोगल क्यों किया गया है। मैं downloaded the app और तुरंत एक बफर के साथ एक बग ठीक करना पड़ा जो बहुत छोटा था।- यह AddFilter द्वारा ग्राफ में पहले से ही है, लेकिन बाद अभी तक इससे पहले कि इसके उत्पादन पिन जुड़ा हुआ है

Dump Version: 1.2 

Using device: Microsoft® LifeCam Studio(TM) 
Interface: USB 

Pin Name: Capture 
Pin direction: Output 
Pin category: Capture 

IAMVideoCompression: No 
ISpecifyPropertyPages: Yes 
IMediaSeeking: Yes 
IPinConnection: No 
IPinFlowControl: No 
IAMDroppedFrames: No 
IAMVideoProcAmp: No 
IAMVideoControlCaps: 0 

Major Type Sub Type Format Type FixedSamples Temporal Compression Sample Size Max Input Size Min Output Size Max Output Size Min-Max FPS Video Standard 
Video YUY2 VideoInfo Fixed NotTemporal 614400 640x480 640x480 640x480 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 614400 640x480 640x480 640x480 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 1843200 1280x720 1280x720 1280x720 7.50-10.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 1843200 1280x720 1280x720 1280x720 7.50-10.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 1044480 960x544 960x544 960x544 7.50-20.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 1044480 960x544 960x544 960x544 7.50-20.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 716800 800x448 800x448 800x448 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 716800 800x448 800x448 800x448 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 460800 640x360 640x360 640x360 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 460800 640x360 640x360 640x360 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 203520 424x240 424x240 424x240 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 203520 424x240 424x240 424x240 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 202752 352x288 352x288 352x288 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 202752 352x288 352x288 352x288 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 153600 320x240 320x240 320x240 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 153600 320x240 320x240 320x240 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 960000 800x600 800x600 800x600 7.50-20.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 960000 800x600 800x600 800x600 7.50-20.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 50688 176x144 176x144 176x144 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 50688 176x144 176x144 176x144 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 38400 160x120 160x120 160x120 7.50-30.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 38400 160x120 160x120 160x120 7.50-30.00 {none} 
Video YUY2 VideoInfo Fixed NotTemporal 4147200 1920x1080 1920x1080 1920x1080 5.00-5.00 {none} 
Video YUY2 VideoInfo2 Fixed NotTemporal 4147200 1920x1080 1920x1080 1920x1080 5.00-5.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 921600 640x480 640x480 640x480 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 921600 640x480 640x480 640x480 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 6220800 1920x1080 1920x1080 1920x1080 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 6220800 1920x1080 1920x1080 1920x1080 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 2764800 1280x720 1280x720 1280x720 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 2764800 1280x720 1280x720 1280x720 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 1566720 960x544 960x544 960x544 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 1566720 960x544 960x544 960x544 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 1075200 800x448 800x448 800x448 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 1075200 800x448 800x448 800x448 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 691200 640x360 640x360 640x360 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 691200 640x360 640x360 640x360 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 1440000 800x600 800x600 800x600 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 1440000 800x600 800x600 800x600 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 311040 432x240 432x240 432x240 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 311040 432x240 432x240 432x240 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 304128 352x288 352x288 352x288 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 304128 352x288 352x288 352x288 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 76032 176x144 176x144 176x144 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 76032 176x144 176x144 176x144 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 230400 320x240 320x240 320x240 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 230400 320x240 320x240 320x240 7.50-30.00 {none} 
Video MJPG VideoInfo Fixed NotTemporal 57600 160x120 160x120 160x120 7.50-30.00 {none} 
Video MJPG VideoInfo2 Fixed NotTemporal 57600 160x120 160x120 160x120 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 460800 640x480 640x480 640x480 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 460800 640x480 640x480 640x480 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 1382400 1280x720 1280x720 1280x720 7.50-15.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 1382400 1280x720 1280x720 1280x720 7.50-15.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 783360 960x544 960x544 960x544 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 783360 960x544 960x544 960x544 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 537600 800x448 800x448 800x448 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 537600 800x448 800x448 800x448 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 345600 640x360 640x360 640x360 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 345600 640x360 640x360 640x360 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 152640 424x240 424x240 424x240 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 152640 424x240 424x240 424x240 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 152064 352x288 352x288 352x288 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 152064 352x288 352x288 352x288 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 115200 320x240 320x240 320x240 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 115200 320x240 320x240 320x240 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 720000 800x600 800x600 800x600 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 720000 800x600 800x600 800x600 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 38016 176x144 176x144 176x144 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 38016 176x144 176x144 176x144 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 28800 160x120 160x120 160x120 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 28800 160x120 160x120 160x120 7.50-30.00 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo Fixed NotTemporal 3110400 1920x1080 1920x1080 1920x1080 7.50-7.50 {none} 
Video {3032344D-0000-0010-8000-00AA00389B71} VideoInfo2 Fixed NotTemporal 3110400 1920x1080 1920x1080 1920x1080 7.50-7.50 {none} 

Pin Name: Video Camera Terminal 
Pin direction: Input 
Pin category: {3EBC7959-3310-493B-AA81-C7E132D56F71} 

IAMVideoCompression: No 
ISpecifyPropertyPages: Yes 
IMediaSeeking: No 
IPinConnection: No 
IPinFlowControl: No 
IAMDroppedFrames: No 
IAMVideoProcAmp: No 
IAMVideoControlCaps: 0 

Major Type Sub Type Format Type FixedSamples Temporal Compression Sample Size 

उत्तर

3

आप इसे सही जगह में डाल दिया: को सुलझाने कि मैं निम्नलिखित रिपोर्ट उत्पन्न करने में सक्षम था के बाद। यदि आपने HRESULT को सफल किया है, तो आप बदलते प्रारूप की अपेक्षा कर सकते हैं, लेकिन अपवाद हो सकते हैं, उदाहरण के लिए इस मीडिया प्रकार को डाउनस्ट्रीम फ़िल्टर द्वारा स्वीकार नहीं किया गया था और उन्होंने शुरुआत से बातचीत शुरू कर दी थी।

आप यहां अपना कॉन्फ़िगर नमूनाग्राबर नहीं दिखा रहे हैं, इसलिए यह हो सकता है कि आप जिस मीडिया प्रकार को चाहते हैं वह वैकल्पिक मीडिया प्रकारों और/या इंटरमीडिएट फ़िल्टर (जैसे डिकोडर्स) को आज़माने के लिए नमूना हथियार बनाने वाले फ़िल्टर ग्राफ़ द्वारा स्वीकार नहीं किया जाता है।

कुछ ऐसी चीजें हैं जो आप वास्तव में कर सकते हैं।

  1. समस्या निवारण आप के लिए चाहते हो सकता है के लिए:

    1. add the filter graph to ROT, या बजाय सिर्फ install DirectShow Spy ही आप के लिए स्वचालित रूप से किया
    2. सही अपने SetCaptureFormat के बाद अपने कोड में एक संदेशबॉक्स जोड़ने के लिए
    3. जबकि संदेश बॉक्स अभी भी स्क्रीन पर है, अपने फ़िल्टर ग्राफ़ का निरीक्षण करने के लिए ग्राफ़एडिट (GraphStudio) का उपयोग करें और यह देखने के लिए कि इसके आउटपुट पिन पर यह किस प्रकार के मीडिया का अनुमान लगाता है; आम तौर पर पहले मीडिया प्रकार असली कनेक्शन के लिए प्रयोग किया जाता है, इसलिए SetFormat में अपनी सफल HRESULT मूल रूप से मान लिया गया मीडिया प्रकार इस सूची
  2. मीडिया प्रकार बाध्य करने के लिए की चोटी पर अब है, तो आप उपयोग कर सकते हैं IFilterGraph :: कॉन्फ़िगर किए गए पिन के साथ कनेक्ट डायरेक्ट, यह तत्काल पड़ोसी डाउनस्ट्रीम पिन और आपकी रुचि के मीडिया प्रकार है।

उम्मीद है कि इससे मदद मिलती है।

+0

मैंने कॉन्फ़िगर SampleGrabber() विधि को शामिल करने के लिए मूल पोस्ट को अद्यतन किया है। इस बीच में मैं आपके सूचीबद्ध अतिरिक्त विकल्पों को देखूंगा। उत्तर –

+0

के लिए धन्यवाद तो यह बात है: आप शायद कैमरे पर गैर-आरजीबी मीडिया प्रकार सेट कर रहे हैं, और आप नमूना ग्रैबर को केवल आरजीबी वीडियो स्वीकार करने के लिए सेट करते हैं। फिर आप अनुरोध करते हैं कि ये दो चीजें एक साथ जुड़े हुए हैं ... यह तब भी हो सकता है जब (ए) कैमरा किसी अन्य मीडिया प्रकार का प्रयास करने का निर्णय लेता है, न कि जिसे आपने इसका उपयोग करने का निर्देश दिया है, या (बी) एक और इंटरमीडिएट फ़िल्टर होगा और फिर मीडिया प्रकार परिवर्तन होता है। –

+1

... जैसा कि मैंने उपरोक्त लिखा है, या एक अतिरिक्त नमूना हथियार डालने से आप मीडिया प्रकार को स्पष्ट रूप से सेट करके इसे काम कर सकते हैं, जो कैमरा फ़िल्टर के तुरंत बाद किसी भी वीडियो को स्वीकार करता है, ताकि सभी निम्नलिखित ओपेशन में एसजी के आउटपुट पिन शामिल हों, न कि कैमरे। यह सेटफॉर्मैट के माध्यम से चुने गए मूल मीडिया प्रकार को सुरक्षित रखेगा। –

0

स्टीव, आपको SetCaptureFormat में कैमरे (मोनिकर से) का पुनर्निर्माण नहीं करना चाहिए, लेकिन g_pIBaseFilterCam का उपयोग करें।