aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/widgets
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-10-04 09:52:01 -0400
committerKen Moore <ken@ixsystems.com>2017-10-04 09:52:01 -0400
commit15d8dac497768350ea429d6c6682ed9723d0464c (patch)
treeb6238a9d934b8aca88122306fa1f90f06cc394fe /src-qt5/desktop-utils/lumina-fm/widgets
parentFinish up the auto archive/extract within lumina-archiver (with JT) (diff)
parentFurther lumina-fm changes for video thumbnails (diff)
downloadlumina-15d8dac497768350ea429d6c6682ed9723d0464c.tar.gz
lumina-15d8dac497768350ea429d6c6682ed9723d0464c.tar.bz2
lumina-15d8dac497768350ea429d6c6682ed9723d0464c.zip
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/widgets')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp72
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h38
2 files changed, 62 insertions, 48 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
index ee7fb9e3..d0ecdecf 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp
@@ -1,33 +1,59 @@
-#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
+#ifndef VIDNAIL_H
+#define VIDNAIL_H
+
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
}
-vidnail::~vidnail()
-{
+class 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();
+struct vFrame {
+ vFrame() : *width(0), *height(0) {}
+ vFrame(int *width, int *height : width(width), height(height) {}
+ int *width;
+ int *height;
+};
- currentFrame = frame;
- const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- const QSize size = format.frameSize();
+public:
- this->imageFormat = imageFormat;
- QAbstractVideoSurface::start(format);
- QImage image( currentFrame.bits(), currentFrame.width(), currentFrame.height(), currentFrame.bytesPerLine(), imageFormat);
- imageCaptured = QPixmap::fromImage(image.copy(image.rect()));
+ QString getCodec();
+ void skipTo(int timeInSeconds);
+ void readVideoFrame();
+ void getScaledVideoFrame(int scaledSize, vFrame& vFrame);
-// Now do scaling with regular thumbnail process to make proper size
+ int getWidth();
+ int getHeight();
+ int getLength();
+
+ void makeThumbnail(const QString& videoFile, QImage &image);
+ void setThumbnailSize(int size);
+ void setPercentage(int percent);
+ void setTime(const QString& Time);
+
+ void writeVidNail(vFrame& frame, QImage& image);
+
+
+ private:
+ bool readVideoPacket();
+ bool getVideoPacket();
+ void scaleVideo(int scaledSize, int& scaledWidth, int& scaledHeight);
+ void createVFrame(AVFrame *vFrame, quint8 *frameBuffer, int width, int height);
+ void calculateDimensions(int size);
+ void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage& image);
+ QString getMimeType(const QString& videoFile);
+ QString getExtension(const QString& videoFilename);
- mplayer.stop();
- vsurface.stop();
-}
+ private:
+ int videoStream;
+ AVFormatContext *inputVideoFormatContext;
+ AVCodecContext *inputvideoCodecContext;
+ AVCodec *inputVideoCodec;
+ AVStream *inputVideoStream;
+ AVFrame *inputVideoFrame;
+ quint8 *inputFrameBuffer;
+ AVPacket *videoPacket;
+#endif // VIDNAIL_H
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h
index ad565749..e13894e1 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h
@@ -1,25 +1,13 @@
-#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
-
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2017, q5sys
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "vidnail.h"
+
+VidNail::VidNail(QObject *parent) : QObject(parent){
+}
+
+VidNail::~VidNail(){
+}
bgstack15