IMediaControl.Run()成功,相机预览仍为黑色 [英] IMediaControl.Run() is successful still camera preview is black

查看:97
本文介绍了IMediaControl.Run()成功,相机预览仍为黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过使用Directshow.NET和c#,我开发了一个显示摄像机预览的应用程序。自1年以来一切正常,但突然客户抱怨黑色摄像头预览。

By using Directshow.NET and c# I have developed an application which shows camera preview. Everything is working fine since 1 year but suddenly client complaint about black camera preview.

经过一番挖掘后,我知道反病毒程序正在阻止我的应用程序使用相机。在将我的应用程序添加到该防病毒程序的排除列表后,该应用程序便可以像以前一样工作。

After some digging to issue I come to know that anti-virus program is blocking camera usages by my application. After adding my application in exclusion list of that anti-virus program makes application to work as like before.

在程序中,我正确抛出了的异常HRESULT 如下:

In program I have properly thrown exception for HRESULT like below:

try
{
    //FilterGraph creation
    //CaptureGraphBuilder2 creation
    //AddSourceFilterForMoniker()
    //SampleGrabber configuration
    //VMR9 configuration

    hr = mediaControl.Run();
    DsError.ThrowExceptionForHR(hr);
}
catch(Exception ex)
{
    //logging part
}

仍然没有任何日志记录,即使我在该特定机器上调试了该应用程序,但程序仍成功执行。
因此,问题是,要避免此类问题,我如何确保相机预览实际上已启动?有什么方法可以检查流是否被阻止。

Still there is nothing in log, even I debug that application on that particular machine but program executes successfully. So the question is, To avoid such issues how can I make sure that camera preview is actually started? Is there any way to check that stream is not blocked.

推荐答案

黑色摄像头预览不一定是无法运行图形的症状。例如,不管这究竟是您的问题,还是过滤器图esp。显示IP摄像机供稿的状态可能会处于运行状态,而视频渲染器会期望帧分别被接收和处理为显示就绪状态。但是,如果防病毒软件或防火墙阻止了流量,则视频帧将永远无法到达渲染器。过滤器图仍在运行,并且没有故障或错误。

Black camera preview is not necessarily a symptom of a failure to run the graph. For example, whether this is your problem exactly or not, a filter graph esp. displaying IP camera feed might be put into running state and the video renderer would expect a frame to be received and processed respectively to the state it's display ready. However if an antivirus or a firewall blocks traffic, the video frame never reaches the renderer. The filter graph is running though and there is no failure or error.

通常,您希望从过滤器图中的过滤器中请求一些统计信息,以证明正在进行有效负载处理。这可能包括:

You normally want to request some statistics from filters in your filter graph, that prove there is payload processing happening. This might include:


  • 来自源过滤器的查询,它实际上会产生数据

  • 中间组件例如能够提供已处理数据统计信息的解码器

  • 流水线中的Sample Grabber过滤器,具有无需修改即可对样本进行计数的回调

  • 统计请求从视频渲染器(例如 IQualProp :: get_FramesDrawn ...检索自流开始以来实际绘制的帧数)

  • 尝试从视频渲染器中读取当前显示的视频帧的快照

  • a query from source filter that it actually produces data
  • an intermediate component such as decoder capable to provide stats of processed data
  • a Sample Grabber filter in the pipeline with a callback counting samples without modification
  • a request of statistics from video renderer (such as e.g. IQualProp::get_FramesDrawn "...retrieves the number of frames actually drawn since streaming started")
  • an attempt to read back a snapshot of currently displayed video frame from video renderer

一旦您看到数据正在按时间进行处理当然,您不会发生意外的锁定。

Once you see the data is being processed as the time goes, you know there is no unexpected locking happens.

这篇关于IMediaControl.Run()成功,相机预览仍为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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