mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
51066e5478
commit
fce42d4858
14 changed files with 727 additions and 20 deletions
37
core/videoframeextractor.h
Normal file
37
core/videoframeextractor.h
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue