aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
blob: ee7fb9e3a258a0966149b36d07f7d7b860531505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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();
}



bgstack15