summaryrefslogtreecommitdiffstats
path: root/core/videoframeextractor.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-07-10 15:04:35 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-28 15:31:25 -0700
commitfce42d4858d33e10b7a1c48d75838f1901b6b123 (patch)
tree3be7516c1e306e4fb8cce9cd1f3e357e3a5575df /core/videoframeextractor.h
parent51066e5478d76824c5da53f37184e0e0d1f3e4af (diff)
downloadsubsurface-fce42d4858d33e10b7a1c48d75838f1901b6b123.tar.gz
Dive media: Extract thumbnails from videos with ffmpeg
Extract thumbnails using ffmpeg. Behavior is controlled by three new preferences fields: - extract_video_thumbnails (bool): if true, thumbnails are calculated. - extract_video_thumbnail_position (int 0..100): position in video where thumbnail is fetched. - ffmpeg_executable (string): path of ffmpeg executable. If ffmpeg refuses to start, extract_video_thumbnails is set to false to avoid unnecessary churn. Video thumbnails are marked by an overlay. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/videoframeextractor.h')
-rw-r--r--core/videoframeextractor.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/core/videoframeextractor.h b/core/videoframeextractor.h
new file mode 100644
index 000000000..26650af8d
--- /dev/null
+++ b/core/videoframeextractor.h
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef VIDEOFRAMEEXTRACTOR_H
+#define VIDEOFRAMEEXTRACTOR_H
+
+#include "core/units.h"
+
+#include <QMutex>
+#include <QFuture>
+#include <QThreadPool>
+#include <QQueue>
+#include <QString>
+#include <QPair>
+
+class VideoFrameExtractor : public QObject {
+ Q_OBJECT
+public:
+ VideoFrameExtractor();
+ static VideoFrameExtractor *instance();
+signals:
+ void extracted(QString filename, QImage, duration_t duration, duration_t offset);
+ // There are two failure modes:
+ // failed() -> we failed to start ffmpeg. Write a thumbnail signalling "maybe try again".
+ // invalid() -> we started ffmpeg, but that couldn't extract an image. Signal "this file is broken".
+ void failed(QString filename, duration_t duration);
+ void invalid(QString filename, duration_t duration);
+public slots:
+ void extract(QString originalFilename, QString filename, duration_t duration);
+ void clearWorkQueue();
+private:
+ void processItem(QString originalFilename, QString filename, duration_t duration);
+ void fail(const QString &originalFilename, duration_t duration, bool isInvalid);
+ mutable QMutex lock;
+ QThreadPool pool;
+ QMap<QString, QFuture<void>> workingOn;
+};
+
+#endif