diff options
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp | 33 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h | 25 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp new file mode 100644 index 00000000..ee7fb9e3 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp @@ -0,0 +1,33 @@ +#include "vidnail.h" +vidnail::vidnail(QWidget *parent) : QMainWindow(parent), mplayer(parent, QMediaPlayer::VideoSurface){ //there is no UI, so not sure how to alter the constructor +} + +vidnail::~vidnail() +{ + +vidnail::grabvideothumbnail(){ + vsurface = new QAbstractVideoSurface(); + mplayer.setVideoOutput(vsurface); + mplayer.setMedia($file); // video file to get thumbnail of + imageCaptured = QPixmap(); + mplayer.setPosition(2000); // time in milliseconds + mplayer.setMuted(true); // just to make sure no sound is emited + mplayer.play(); + + currentFrame = frame; + const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); + const QSize size = format.frameSize(); + + this->imageFormat = imageFormat; + QAbstractVideoSurface::start(format); + QImage image( currentFrame.bits(), currentFrame.width(), currentFrame.height(), currentFrame.bytesPerLine(), imageFormat); + imageCaptured = QPixmap::fromImage(image.copy(image.rect())); + +// Now do scaling with regular thumbnail process to make proper size + + mplayer.stop(); + vsurface.stop(); +} + + + diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h new file mode 100644 index 00000000..ad565749 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h @@ -0,0 +1,25 @@ +#ifndef VIDNAIL_H +#define VIDNAIL_H + +#include <QMediaPlayer> +#include <QtMultimediaWidgets> +#include "videowidgetsurface.h" +#include <QPixmap> +#include <QAbstractVideoSurface> +#include <QImage> +#include <QRect> +#include <QVideoFrame> + +public: + + void grabvideothumbnail(); + +private: + + QAbstractVideoSurface *vsurface; + QImage::Format imageFormat; + QPixmap imageCaptured; + + +#endif // VIDNAIL_H + |