捕获视频流出错:hr = -2147024865(0x8007001f) [英] Capture Video Stream gets an error: hr = -2147024865 ( 0x8007001f )

查看:691
本文介绍了捕获视频流出错:hr = -2147024865(0x8007001f)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!



我用GraphEdit测试了网络摄像头。过滤器图如下:

Hi!

I tested the webcams with GraphEdit. The filter graph is like this:

Webcam 1 -> AVI Decompressor -> Video Renderer

Webcam 2 -> AVI Decompressor -> Video Renderer

Webcam 3 -> AVI Decompressor -> Video Renderer



在某些情况下(使用旧的网络摄像头)它可以工作; somtimes(当新的微软网络摄像头不是第一个被捕获的设备时)它说:

此图表无法播放。连接到系统的设备无法正常工作。(返回代码:0x8007001f )



那么这是否意味着设备存在问题?或者在GraphEdit下做了错误的过滤器图形?





你好专家,



我当前得到的错误就像主题一样。

我的项目是一个用于多个网络摄像头的网络摄像头控制器。我是在winXP,Visual Studio 2010 C ++ Express,WinForm应用程序下编写的。

但我认为它与c#类似,我想你更多的是在c#下编写这样的程序,

所以我也希望c#专家看到它并帮我一个忙。



它适用于旧的3罗技网络摄像头。但是当我添加第四个微软lifcam HD5000时。它显示我连接这个新错误。

错误发生在以下代码行之后:


In some case(with the old webcams) it works; somtimes(when the new microsoft webcam not as the first being captured device) it says:
"This graph can''t play. A device attached to the system is not functioning. (Return code: 0x8007001f)"

So does that mean the problem is of the device? Or did made a wrong filter graph under GraphEdit?


Hello experts,

I currentlly get an error called like topic says.
My project is a webcam controller for multiple webcams. I wrote it under winXP, Visual Studio 2010 C++ Express, WinForm Application.
But I think it''s similar to c# and I thought more of you code such program under c#,
so I''d also like the c# experts to see it and do me a favour.

It works well with the old 3 logitech webcams. But when I added a fourth Microsoft lifcam HD5000. It shows me en error to connect this new one.
The error is after this code line:

hr = test2.pMC->Run();



* pMC指向IMediaControl。 test2是我的CamShow类的对象2,用于捕获视频流。

hr的返回值是-2147024865。我想说这是一个未知的错误。

但是在不同的PC上多次尝试之后,返回值总是如此。



当我在win7 PC上运行这个版本时,同样的错误也发生了。



我发布了如何捕获视频中的视频流的方式。这有点长,我希望你有耐心和时间去看。否则,如果你对我有疑问,我很高兴回答。

如果你之前也看到同样的错误并且知道解决方案,那将是一个好处。或者如果你很高兴能帮助看到原因,我会感激不尽!我真的需要你的帮助!



CamShow.h


*pMC points to the IMediaControl. The test2 is object 2 of my CamShow Class, for capturing the videostream.
The return value of hr is -2147024865. I''d like say that to be an unkown error.
But after several tries on different PCs, the return values is always this.

The same error has also happened when I run the release in win7 PC.

I post the way how I capture the video steams in the buttom. It''s a little long, I hope you have patient and time to see it. Otherwise if you have question on me, I''m very glad to answer.
It will be such a benefitIf if you have also seen the same error before and know the solution. Or if you are glad to help to see the reason, I''ll be thankful! I really need your help!

CamShow.h

#include <DShow.h>
#include <Windows.h>
#define SAFE_RELEASE(x) {if (x) x->Release(); x=NULL;}
#define WM_GRAPHNOTIFY  WM_APP+1


class CamShow
	{
	public: CamShow(); 
		~CamShow();

	public:	// methods
		HRESULT	InitComLib();
		HRESULT	CaptureVideo(int);
		HRESULT	FindCaptureDevice(IBaseFilter **ppSrcFilter, int);

                HRESULT GetInterfaces();
                HRESULT	Stop();
                void    CloseInterfaces(void);
                void    ControlRelease();
                void    EventRelease();
                void    GraphBuilderRelease();
                void    CoUnini();

public: 
            HRESULT                     hr;
            IGraphBuilder               *pGraphBuilder;
            ICaptureGraphBuilder        *pCGB;
            ICaptureGraphBuilder2       *pCGB2;
            IVideoWindow                *pVW;

            IMediaControl               *pMC;
            IMediaEventEx               *pME;

            HWND                        ghApp;
            DWORD                       g_dwGraphRegister;
};





CamShow.cpp



CamShow.cpp

#include "stdafx.h"
#include "CamShow.h"

    CamShow::CamShow()
    {       hr                          = NULL;
            pGraphBuilder               = NULL;
            pCGB                        = NULL;
            pCGB2                       = NULL;
            pVW                         = NULL;

            pMC                         = NULL;
            pME                         = NULL;

            ghApp                       = 0;
            g_dwGraphRegister           = 0;

    }
    CamShow::~CamShow() {}


    HRESULT CamShow::InitComLib()
    {
        hr = CoInitialize(NULL);
        return hr;
    }

    HRESULT CamShow::CaptureVideo(int NO)
    {
	IBaseFilter *pSrcFilter	= NULL;
	IBaseFilter *pSampleGrabberFilter = NULL;

        hr = pCGB2->SetFiltergraph(pGraphBuilder);
        if (FAILED(hr))
        {
        MessageBox(NULL,TEXT("Set FilterGraph error!"), NULL, MB_OK | MB_ICONINFORMATION);
            return hr;
        }


        hr = FindCaptureDevice(&pSrcFilter, NO);
        if (FAILED(hr))
        {
            return hr;
        }
        
        hr = pGraphBuilder->AddFilter(pSrcFilter, L"Capture Filter");
        if (FAILED(hr))
        {
            MessageBox(NULL, TEXT("AddFilter error! \r\n"), NULL, MB_OK | MB_ICONINFORMATION);
            pSrcFilter->Release();
            return hr;
        }
        
        hr = pCGB2->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
                                       pSrcFilter, NULL, NULL);
        if (FAILED(hr))
        {
            MessageBox(NULL, TEXT("Rendering stream error!"), NULL, MB_OK | MB_ICONINFORMATION);
            pSrcFilter->Release();
            return hr;
        }

        pSrcFilter->Release();
        
        return S_OK;
    }

    HRESULT CamShow::FindCaptureDevice(IBaseFilter ** ppSrcFilter, int NO)
	{
	 HRESULT	hr = S_OK;
	 IBaseFilter *pSrc	= NULL;
	 IMoniker *pMoniker	= NULL;
	 ULONG cFetched;
	 int	DevNO = 0;

         IEnumMoniker *pClassEnum = NULL;
	 ICreateDevEnum *pDevEnum = NULL;

	 if (!ppSrcFilter)
	     return E_POINTER; 		
	
	 hr = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
				IID_ICreateDevEnum, (void **) &pDevEnum);
	 if (FAILED(hr))
	 {
	 MessageBox(NULL,TEXT("system enumerator not able to be created!"), NULL, MB_OK | MB_ICONINFORMATION);
	 }
	
	if (SUCCEEDED(hr))
	{
	 hr = pDevEnum->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, 
                                               &pClassEnum, 0);
	 if (FAILED(hr))
	 {
	 MessageBox(NULL, TEXT("class enum can't be created! hr=0x%x"), NULL, MB_OK | MB_ICONINFORMATION);
	 }
	
         pDevEnum->Release();
       }
       
        if (SUCCEEDED(hr))
        {
            if (pClassEnum == NULL)
            {
            MessageBox(ghApp,TEXT("No usable webcams!\r\n\r\n"),
                    TEXT(""), MB_OK | MB_ICONINFORMATION);
                hr = E_FAIL;
            }
        }

        while (pClassEnum->Next(1, &pMoniker, &cFetched) == S_OK)
        {
            DevNO++;

            if (DevNO==NO)
            {
            hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void **)&pSrc);
            if (FAILED(hr))
              return hr;

            pMoniker->Release();
            break;
            }
        }

        // Copy the found filter pointer to the output parameter.
        if (SUCCEEDED(hr))
        {
            *ppSrcFilter = pSrc;
            (*ppSrcFilter)->AddRef();
        }

        return hr;
     }


     HRESULT CamShow::GetInterfaces()
     {
        // Create the filter graph
        hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
                               IID_IGraphBuilder, (void **) &pGraphBuilder);
        if (FAILED(hr))
            return hr;

        // Create the capture graph builder
        hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,
                               IID_ICaptureGraphBuilder2, (void **) &pCGB2);
        if (FAILED(hr))
            return hr;

        // Obtain interfaces for media Control and Video Window
        hr = pGraphBuilder->QueryInterface(IID_IMediaControl,(LPVOID *) &pMC);
        if (FAILED(hr))
        return hr;

        hr = pGraphBuilder->QueryInterface(IID_IVideoWindow, (LPVOID *) &pVW);
        if (FAILED(hr))
        return hr;

        hr = pGraphBuilder->QueryInterface(IID_IMediaEvent, (LPVOID *) &pME);
        if (FAILED(hr))
        return hr;

        
        return hr;
    }
   
    HRESULT CamShow::Stop()
    {
        if (pMC!=NULL)
        {
        hr = pMC->Stop();
        SAFE_RELEASE(pMC);
        }
        return hr;
    }

    void CamShow::CloseInterfaces()
    {
        // stop previewing data
        if (pMC)
            pMC->StopWhenReady();

        // stop receiving events
        if (pME)
            pME->SetNotifyWindow(NULL, WM_GRAPHNOTIFY, 0);

        // Relinquish ownership (IMPORTANT!) of the video window.
        // Failing to call put_Owner can lead to assert failures within
        // the video renderer, as it still assumes that it has a valid
        // parent window. 
        if (pVW)
        {
            pVW->put_Visible(OAFALSE);
            pVW->put_Owner(NULL);
        }

        SAFE_RELEASE(pMC);
        SAFE_RELEASE(pME);
        SAFE_RELEASE(pVW);
        SAFE_RELEASE(pCGB2);
        SAFE_RELEASE(pGraphBuilder);
    }

    void CamShow::ControlRelease()
    {
        pMC->Release();
    }
    void CamShow::EventRelease()
    {   pME->Release();
    }
    void CamShow::GraphBuilderRelease()
    {   pGraphBuilder->Release();
    }

    void CamShow::CoUnini()
    {
        CoUninitialize();
    }





Form1.h



Form1.h

#pragma once

#include "CamShow.h"
#include "GlobalVar.h"

CamShow test1;
CamShow test2;
CamShow test3;

namespace My3Cam {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
        }
    protected:
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::PictureBox^  pictureBox1;
    protected:
    private: System::Windows::Forms::PictureBox^  pictureBox2;
    private: System::Windows::Forms::PictureBox^  pictureBox3;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Button^  button2;

    
    private:
             System::ComponentModel::Container ^components;

    private: static HRESULT hr = NULL;
   
    ......(Windows Form Designer generated code) 





点击连接



Click "Connect"

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

                 button1->Enabled=false;
                 button2->Enabled=true;

                 hr = test1.InitComLib();
                 hr = test1.GetInterfaces();
                 hr = test1.CaptureVideo(2);

                 System::Drawing::Rectangle rc = pictureBox1->ClientRectangle;
                 hr = test1.pVW->put_Owner(OAHWND(this->pictureBox1->Handle.ToInt64()));
                 hr = test1.pVW->put_WindowStyle( WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
                 hr = test1.pVW->SetWindowPosition( 0, 0, rc.Right, rc.Bottom );
                 hr = test1.pMC->Run();

                 test1.CoUnini();

                 ///////////////////////////////////test2///////////////////////////////////////////////
                 hr = test2.InitComLib();
                 hr = test2.GetInterfaces();
                 hr= test2.CaptureVideo(1);

                 System::Drawing::Rectangle rc2 = pictureBox2->ClientRectangle;
                 hr = test2.pVW->put_Owner(OAHWND(this->pictureBox2->Handle.ToInt64()));
                 hr = test2.pVW->put_WindowStyle( WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
                 hr = test2.pVW->SetWindowPosition( 0, 0, rc2.Right, rc2.Bottom );
                 hr = test2.pMC->Run();

                 test2.CoUnini();

                 //////////////////////////////////////test3/////////////////////////////////////////////
                 hr = test3.InitComLib();
                 hr = test3.GetInterfaces();
                 hr= test3.CaptureVideo(3);

                 System::Drawing::Rectangle rc3 = pictureBox3->ClientRectangle;
                 hr = test3.pVW->put_Owner(OAHWND(this->pictureBox3->Handle.ToInt64()));
                 hr = test3.pVW->put_WindowStyle( WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
                 hr = test3.pVW->SetWindowPosition( 0, 0, rc3.Right, rc3.Bottom );
                 hr = test3.pMC->Run();

                 test3.CoUnini();


}



实际上我在原始程序中使用了三个组合框来读取PC上的所有视频设备,并选择一个用于每个pictureBox。这里我简化了一下,但它足以显示错误。并且在我测试时,它运行时没有代码错误。

只是pictureBox,在pMC-> Run()之后有hr = -214724865,显示黑色图像。



如果你想要要更改每个图片框中的网络摄像头,只需更改三个剪辑中的值:


Acturally I used three comboBoxes in my original program to read all video devices on PC, and to choose one for each pictureBox. Here I''ve simplified that, but it is enough to show the error. And as I tested, it runs without code error.
Just the pictureBox, which has hr = -214724865 after pMC->Run(), shows black image.

If you want to change the turns of webcams in each pictureBoxes, just change the value in the three clips:

hr = test1.CaptureVideo(2);
hr = test2.CaptureVideo(1);
hr = test3.CaptureVideo(3);



它可以是1到n,n是所有设备的数量。例如,有6个网络摄像头,

然后你可以选择1,5,4来捕获。



点击断开连接


it can be 1 to n, n is the number of all devices. For example, there are 6 webcams,
then you can choose the 1, 5, 4 to capture.

Click "Disconnect"

private: System::Void button2_Click_1(System::Object^  sender, System::EventArgs^  e) {
             btnConnect->Enabled = true;
             btnDisconnect->Enabled = false;
             test1.Stop();
             test2.Stop();
             test3.Stop();
         }

推荐答案

不是答案,而是各种系统的错误描述,因此绝对不是未知错误:



Not an answer, but the error description from various systems, so it is definitely not an unknown error:

C:\DevTools>err 0x8007001f
# as an HRESULT: Severity: FAILURE (1), Facility: 0x7, Code 0x1f
# for hex 0x1f / decimal 31 :
  BTH_ERROR_UNSPECIFIED_ERROR                                   bthdef.h
  SHARED_RESOURCE_CONV_ERROR                                    bugcodes.h
  EVENT_MSCEP_FAIL_SUBMIT                                       ceplog.mc
# SCEP Add-on cannot submit certificate request.
# ICertRequest::Submit failed (%2).  %3  Please find support
# information at http://%1/certsrv/mscep/mscephlp.htm.
  MSG_E_BAD_CA_CHAIN                                            certlog.mc
# Certificate Services did not start: The chain of
# Certification Authority certificates is not properly
# configured.
  CR_INVALID_DATA                                               cfgmgr32.h
  IAAPI_BADOBJ                                                  iaapi.h
# /* Object can not be marked */
  KRB_AP_ERR_BAD_INTEGRITY                                      kerberr.h
# Integrity check on decrypted field failed
  POLICY_ERRV_SUBNET_USER_PEAK_RATE                             lpmapi.h
  MAPI_DIAG_RENDITION_UNSUPPORTED                               mapidefs.h
  NMERR_NO_PROPERTY_DATABASE                                    netmon.h
  OLE_ERROR_NEW,                                                ole.h
# Server failed to create new doc         */
  SE_ERR_NOASSOC                                                shellapi.h
  MSG_TIME_ZONE_FIXED                                           w32timemsg.mc
# The time service discovered that the system time zone
# information was
# corrupted. Because many system components require valid
# time zone
# information, the time service has reset the system time
# zone to GMT.
# Use the Date/Time control panel to set the correct time
# zone.
  ERROR_GEN_FAILURE                                             winerror.h
# A device attached to the system is not functioning.
# 14 matches found for "0x8007001f"


这篇关于捕获视频流出错:hr = -2147024865(0x8007001f)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆