简体   繁体   English

在GStreamer视频上叠加其他GUI元素

[英]Overlay Other GUI Elements Over GStreamer Video

I have a project built in Python, PyGTK 2.24, and PyGST (GStreamer). 我有一个用Python,PyGTK 2.24和PyGST(GStreamer)构建的项目。 I have my video working perfectly in a gtk.DrawingArea object. 我的视频在gtk.DrawingArea对象中运行良好。

However, I need to display other GUI elements OVER this video while it is playing. 但是,我需要在播放视频时在该视频上显示其他GUI元素。 (Please don't ask why, just trust me.) Right now, they all appear to be behind. (请不要问为什么,请相信我。)现在,它们似乎都落后了。 In the code, the video objects (and gtk.DrawingArea) are declared and put into the gtk.Fixed FIRST, following by everything else. 在代码中,声明了视频对象(和gtk.DrawingArea),并将其放入gtk.Fixed FIRST中,接着是其他所有内容。

So, how do I do this? 那么,我该怎么做呢? Do I need to change what object GStreamer is playing on? 我是否需要更改正在播放GStreamer的对象? I know it is possible...I've seen GStreamer programs that have things like buttons and labels sitting on top of the video. 我知道这是有可能的...我看过GStreamer程序,这些程序在视频的顶部都有按钮和标签。

Thanks in advance! 提前致谢!

Probably of no use to the OP, but I searched for a long time looking for a way to place widgets over the top of a gtk.gdk.Drawable element (which could be a statically drawn image, animation or video) before I finally figured out how to do this in pygtk2. 可能对OP没有用,但我花了很长时间寻找一种将小部件放置在gtk.gdk.Drawable元素(可以是静态绘制的图像,动画或视频)上方的方法。找出如何在pygtk2中执行此操作。

Here's a link to what I came up with: http://bazaar.launchpad.net/~damien-moore/picty/trunk/view/642/modules/picty/overlay_widgets.py 这是我想出的东西的链接: http : //bazaar.launchpad.net/~damien-moore/picty/trunk/view/642/modules/picty/overlay_widgets.py

This includes 3 custom classes: 这包括3个自定义类:

ProportionalLayout: an implementation of a custom gtk.Container that lets the user position child widgets using proportions. ProportionalLayout:自定义gtk.Container的实现,允许用户使用比例来定位子窗口小部件。

DrawableOverlay: an EventBox that emits a 'draw' event for the user to connect to and do drawing on, and displays a ProportionalLayout on top. DrawableOverlay:一个EventBox,它发出一个“绘制”事件供用户连接并在其上进行绘制,并在顶部显示一个ProportionalLayout。

DrawableOverlayHover: a DrawableOverlayHover that only shows the widgets if the pointer gets "close" to them. DrawableOverlayHover:DrawableOverlayHover,它仅在指针与窗口小部件“接近”时才显示窗口小部件。

The sample main program illustrates how to use them. 样品主要程序说明如何使用它们。 The code should be reasonably straightforward to adapt to a video application. 该代码应相当简单,以适应视频应用程序。

You can do this in GTK 3.2 and above using GtkOverlay . 您可以在GTK 3.2及更高版本中使用GtkOverlay进行此GtkOverlay

If you can't upgrade, then here is a summary of the old-fashioned way: connect to the expose-event signal of the DrawingArea , and paint the information on yourself using Cairo. 如果您不能升级,那么这里是老式方式的摘要:连接到DrawingAreaexpose-event信号,然后使用开罗在您自己DrawingArea绘制信息。 When the information changes, trigger a redraw of the drawing area using widget.queue_draw() . 信息更改时,使用widget.queue_draw()触发对绘图区域的重绘。 Make sure your handler runs after the handler that draws the actual video onto the drawing area. 确保您的处理程序在将实际视频绘制到绘图区域的处理程序之后运行。 This will work for labels and non-interactive GUI elements. 这将适用于标签和非交互式GUI元素。

If you want an actual functioning GUI element to hover above your video, that's rather more complicated and I don't know how to do it. 如果您希望将实际起作用的GUI元素悬停在视频上方,那会更加复杂,我不知道该怎么做。 I don't think Fixed guarantees any z-order. 我认为Fixed保证任何z顺序。 I suspect that your buttons and whatnot are being overpainted by the video being drawn onto the drawing area, so maybe triggering a redraw of those in your expose-event handler will work. 我怀疑您的按钮和其他内容会被绘制到绘图区域上的视频所覆盖,因此可能会触发您的expose-event处理程序中的按钮重绘有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM