是否可以以编程方式确定视频是否正在播放?

发布于 2024-10-16 20:43:42 字数 94 浏览 1 评论 0原文

是否可以(最好使用.NET)确定视频当前是否正在播放?即使仅限于硬件加速播放,那也比没有好。

如果我可以确定它在多显示器系统中的哪个显示器上播放,那就加分了。

Is it possible (Preferably with .NET) to determine if a video is currently playing? Even if it's limited to hardware accelerated playback, that would be better than nothing.

Bonus points if I can determine what display in a multi-monitor system it's playing on.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

疯狂的代价 2024-10-23 20:43:42

从 alax.info 调查 DirectShowSpy。这将允许您“监视”正在运行的 DirectShow 图形。与 GraphStudio 等工具结合使用非常有用。

我是一名编写 DirectShow 应用程序的 C++ 开发人员,并且一直使用这两个工具,它们是不可或缺的调试工具。

谷歌搜索运行对象表的主题。 DirectShow 图形(通常)添加到运行对象表中,因此您可以枚举 ROT 以确定系统上正在运行哪些图形。

您的视频卡将使用 DirectShow 渲染器过滤器来播放 Directshow 图表中的视频。渲染器通常由解码器过滤器馈送。解码器过滤器负责解码视频,并且必须指示解码器使用 DXVA 加速。

例如,您在播放图中可能有一个 H.264 解码器过滤器,您必须指示它使用 DXVA 加速。

根据我的经验,解码器过滤器将有一个选项允许您打开/关闭 DXVA 加速视频解码,但这将特定于有问题的解码器,因此普遍检测起来会困难得多。

例如,您可以编写代码来通过查询正在解码 H.264 流的运行图中的解码器过滤器来检测是否启用 DXVA,但查询 VP8 图的解码器过滤器的代码很可能具有不同的代码。

此 MSDN 链接 支持我的经验DXVA加速通过解码器过滤器切换;可能有某种方法可以查询显卡,但我认为这将是 gfx 卡供应商特定的。

抱歉,答案不够具体,但我希望它能为您指明正确的方向......

Investigate DirectShowSpy from alax.info. This will allow you to "spy" on running DirectShow graphs. Very useful in conjunction with a tool like GraphStudio.

I'm a C++ developer writing DirectShow apps, and use both tools all the time, they're indispensable debug tools.

Google the subject of the Running Object Table. DirectShow graphs are (normally) added to the Running Object Table, so you can enumerate the ROT in order to determine what graphs are running on the system.

Your video card will employ a DirectShow renderer filter to playback video within a Directshow graph. The renderer is normally fed by a decoder filter. The decoder filter does the job of decoding video and it is the decoder which must be instructed to use DXVA acceleration.

So for example, you might have an H.264 decoder filter in a playback graph, you must instruct it to use DXVA acceleration.

It has been my experience that the decoder filter will have an option to allow you to turn on / off DXVA accelerated video decoding, but this will be specific to the decoder in question, and therefore it'll be much more difficult to universally detect.

So for example, you might write code to detect if DXVA is enabled by querying the decoder filter in a running graph that's decoding an H.264 stream, but code to query the decoder filter for a VP8 graph will most likely have different code.

This MSDN link supports my experience that DXVA acceleration is toggled through the decoder filter; there may be some way to query a graphics card, but I think this would be gfx card vendor specific.

Sorry the answers weren't more specific, but I hope it points you in the right direction...

ぃ弥猫深巷。 2024-10-23 20:43:42

我认为这不可能在全球范围内实现,因为视频可以通过 DirectX、OpenGL 甚至 GDI 播放。我认为最好的选择是拥有一个用于播放和轮询正在运行的进程的应用程序白名单。一旦你有了这个过程,你就可以尝试找到它的窗口/控件,也许尝试获取 HDC 并使用适当的(最有可能是 DirectShow)API 来查询或操作设备。

当您有一个窗口时,对 System.Windows.Forms.Screen 的简单调用将告诉您哪个屏幕显示这些坐标。

I don't think it's globally possible as video can be played over DirectX, OpenGL or even GDI. I think your best option is to have a white list of applications that are used for playback and poll on running processes. Once you have the process, you can try and find it's windows/controls and maybe try to get the HDC and use the appropriate(DirectShow most probably) API to query or manipulate the device.

When you have a window a simple call to System.Windows.Forms.Screen will tell you what screen is showing these coordinates.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文