From fce42d4858d33e10b7a1c48d75838f1901b6b123 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 10 Jul 2018 15:04:35 +0200 Subject: 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 --- core/imagedownloader.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'core/imagedownloader.h') diff --git a/core/imagedownloader.h b/core/imagedownloader.h index cab945e5f..e0d70f59f 100644 --- a/core/imagedownloader.h +++ b/core/imagedownloader.h @@ -46,6 +46,9 @@ public: public slots: void imageDownloaded(QString filename); void imageDownloadFailed(QString filename); + void frameExtracted(QString filename, QImage thumbnail, duration_t duration, duration_t offset); + void frameExtractionFailed(QString filename, duration_t duration); + void frameExtractionInvalid(QString filename, duration_t duration); signals: void thumbnailChanged(QString filename, QImage thumbnail, duration_t duration); private: @@ -56,22 +59,26 @@ private: }; Thumbnailer(); + Thumbnail fetchVideoThumbnail(const QString &filename, const QString &originalFilename, duration_t duration); + Thumbnail extractVideoThumbnail(const QString &picture_filename, duration_t duration); Thumbnail addPictureThumbnailToCache(const QString &picture_filename, const QImage &thumbnail); - Thumbnail addVideoThumbnailToCache(const QString &picture_filename, duration_t duration); + Thumbnail addVideoThumbnailToCache(const QString &picture_filename, duration_t duration, const QImage &thumbnail, duration_t position); Thumbnail addUnknownThumbnailToCache(const QString &picture_filename); void recalculate(QString filename); void processItem(QString filename, bool tryDownload); Thumbnail getThumbnailFromCache(const QString &picture_filename); Thumbnail getPictureThumbnailFromStream(QDataStream &stream); - Thumbnail getVideoThumbnailFromStream(QDataStream &stream); + Thumbnail getVideoThumbnailFromStream(QDataStream &stream, const QString &filename); Thumbnail fetchImage(const QString &filename, const QString &originalFilename, bool tryDownload); Thumbnail getHashedImage(const QString &filename, bool tryDownload); + void markVideoThumbnail(QImage &img); mutable QMutex lock; QThreadPool pool; QImage failImage; // Shown when image-fetching fails QImage dummyImage; // Shown before thumbnail is fetched QImage videoImage; // Place holder for videos + QImage videoOverlayImage; // Overlay for video thumbnails QImage unknownImage; // Place holder for files where we couldn't determine the type QMap> workingOn; -- cgit v1.2.3-70-g09d2