Qt phonon&qpixmap :: grabwidget
题
我一直在抓住来自帖子媒体对象的帧拍摄几天。我的目标是以用户指定的某些间隔捕获帧。我首先尝试为与敏感:: mableObject相关的刻度信号来实现一个插槽。然而,因为蜱信号在第一个机会中发出有时会在时差中有点种类......不是那么多,这不是一个可行的解决方案,但我仍然进一步调查并尝试了寻求和grabwidget的组合,但它出现了寻求需要一些时间才能完成,并且当视频再次运行时,没有任何方法通知应用程序,这会导致代码如
obj->seek(i*m_grabInterval);
QPixmap image = QPixmap::grabWidget(m_ui.videoPlayer);
.
将黑色图像保存为90%的时间,但正确地抓取框架剩余时间。 我的问题是有什么我可以做的那两个想法中的任何一个都可以让他们为我做好工作,或者我正在咆哮着错误的树,并且有一个更明显的我完全错过了?
提前感谢!
解决方案
你正在咆哮错误的树,这个应该工作,使用Snapshot()func从敏感:: videoWidget 创建qimage
编辑
我进一步调查了这件事。快照功能甚至没有实现。以下是Phonon SRC VideoWidGet.cpp:中的实现
.
QImage VideoWidget::snapshot() const {
P_D(const VideoWidget);
ConstIface<IFACES4> iface(d);
if(iface) return iface->snapshot();
return QImage(); // TODO not implemented in VideoInterface
}
IFACES4指的是videoWidgetInterface44,它为关键字4.4定义,如下所示(来自VideoWidGetInterface.h):
.
class VideoWidgetInterface
{
public:
virtual ~VideoWidgetInterface() {}
virtual Phonon::VideoWidget::AspectRatio aspectRatio() const = 0;
virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio) = 0;
virtual qreal brightness() const = 0;
virtual void setBrightness(qreal) = 0;
virtual Phonon::VideoWidget::ScaleMode scaleMode() const = 0;
virtual void setScaleMode(Phonon::VideoWidget::ScaleMode) = 0;
virtual qreal contrast() const = 0;
virtual void setContrast(qreal) = 0;
virtual qreal hue() const = 0;
virtual void setHue(qreal) = 0;
virtual qreal saturation() const = 0;
virtual void setSaturation(qreal) = 0;
virtual QWidget *widget() = 0;
virtual int overlayCapabilities() const = 0;
virtual bool createOverlay(QWidget *widget, int type) = 0;
};
class VideoWidgetInterface44 : public VideoWidgetInterface
{
public:
virtual QImage snapshot() const = 0;
};
}
#ifdef PHONON_BACKEND_VERSION_4_4
namespace Phonon { typedef VideoWidgetInterface44 VideoWidgetInterfaceLatest; }
#else
namespace Phonon { typedef VideoWidgetInterface VideoWidgetInterfaceLatest; }
#endif
我也看过GStreamer和VLC后端的实现。它们尚未支持来自Phonon 4.4的快照功能。因此,对于野生的时,我将展示其他方法来创建快照。