diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-07-10 15:04:35 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-07-28 15:31:25 -0700 |
commit | fce42d4858d33e10b7a1c48d75838f1901b6b123 (patch) | |
tree | 3be7516c1e306e4fb8cce9cd1f3e357e3a5575df /core/subsurface-qt | |
parent | 51066e5478d76824c5da53f37184e0e0d1f3e4af (diff) | |
download | subsurface-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/subsurface-qt')
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 52 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 28 |
2 files changed, 72 insertions, 8 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 3085216c7..da2a86a68 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1474,6 +1474,21 @@ bool GeneralSettingsObjectWrapper::autoRecalculateThumbnails() const return prefs.auto_recalculate_thumbnails; } +bool GeneralSettingsObjectWrapper::extractVideoThumbnails() const +{ + return prefs.extract_video_thumbnails; +} + +int GeneralSettingsObjectWrapper::extractVideoThumbnailsPosition() const +{ + return prefs.extract_video_thumbnails_position; +} + +QString GeneralSettingsObjectWrapper::ffmpegExecutable() const +{ + return prefs.ffmpeg_executable; +} + void GeneralSettingsObjectWrapper::setDefaultFilename(const QString& value) { if (value == prefs.default_filename) @@ -1579,6 +1594,43 @@ void GeneralSettingsObjectWrapper::setAutoRecalculateThumbnails(bool value) emit autoRecalculateThumbnailsChanged(value); } +void GeneralSettingsObjectWrapper::setExtractVideoThumbnails(bool value) +{ + if (value == prefs.extract_video_thumbnails) + return; + + QSettings s; + s.beginGroup(group); + s.setValue("extract_video_thumbnails", value); + prefs.extract_video_thumbnails = value; + emit extractVideoThumbnailsChanged(value); +} + +void GeneralSettingsObjectWrapper::setExtractVideoThumbnailsPosition(int value) +{ + if (value == prefs.extract_video_thumbnails_position) + return; + + QSettings s; + s.beginGroup(group); + s.setValue("extract_video_thumbnails_position", value); + prefs.extract_video_thumbnails_position = value; + emit extractVideoThumbnailsPositionChanged(value); +} + +void GeneralSettingsObjectWrapper::setFfmpegExecutable(const QString &value) +{ + if (value == prefs.ffmpeg_executable) + return; + + QSettings s; + s.beginGroup(group); + s.setValue("ffmpeg_executable", value); + free((void *)prefs.ffmpeg_executable); + prefs.ffmpeg_executable = copy_qstring(value); + emit ffmpegExecutableChanged(value); +} + LanguageSettingsObjectWrapper::LanguageSettingsObjectWrapper(QObject *parent) : QObject(parent) { diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index cd30cb1ac..a7957f9f1 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -435,14 +435,17 @@ private: class GeneralSettingsObjectWrapper : public QObject { Q_OBJECT - Q_PROPERTY(QString default_filename READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged) - Q_PROPERTY(QString default_cylinder READ defaultCylinder WRITE setDefaultCylinder NOTIFY defaultCylinderChanged) - Q_PROPERTY(short default_file_behavior READ defaultFileBehavior WRITE setDefaultFileBehavior NOTIFY defaultFileBehaviorChanged) - Q_PROPERTY(bool use_default_file READ useDefaultFile WRITE setUseDefaultFile NOTIFY useDefaultFileChanged) - Q_PROPERTY(int defaultsetpoint READ defaultSetPoint WRITE setDefaultSetPoint NOTIFY defaultSetPointChanged) - Q_PROPERTY(int o2consumption READ o2Consumption WRITE setO2Consumption NOTIFY o2ConsumptionChanged) - Q_PROPERTY(int pscr_ratio READ pscrRatio WRITE setPscrRatio NOTIFY pscrRatioChanged) - Q_PROPERTY(bool auto_recalculate_thumbnails READ autoRecalculateThumbnails WRITE setAutoRecalculateThumbnails NOTIFY autoRecalculateThumbnailsChanged) + Q_PROPERTY(QString default_filename READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged) + Q_PROPERTY(QString default_cylinder READ defaultCylinder WRITE setDefaultCylinder NOTIFY defaultCylinderChanged) + Q_PROPERTY(short default_file_behavior READ defaultFileBehavior WRITE setDefaultFileBehavior NOTIFY defaultFileBehaviorChanged) + Q_PROPERTY(bool use_default_file READ useDefaultFile WRITE setUseDefaultFile NOTIFY useDefaultFileChanged) + Q_PROPERTY(int defaultsetpoint READ defaultSetPoint WRITE setDefaultSetPoint NOTIFY defaultSetPointChanged) + Q_PROPERTY(int o2consumption READ o2Consumption WRITE setO2Consumption NOTIFY o2ConsumptionChanged) + Q_PROPERTY(int pscr_ratio READ pscrRatio WRITE setPscrRatio NOTIFY pscrRatioChanged) + Q_PROPERTY(bool auto_recalculate_thumbnails READ autoRecalculateThumbnails WRITE setAutoRecalculateThumbnails NOTIFY autoRecalculateThumbnailsChanged) + Q_PROPERTY(bool extract_video_thumbnails READ extractVideoThumbnails WRITE setExtractVideoThumbnails NOTIFY extractVideoThumbnailsChanged) + Q_PROPERTY(int extract_video_thumbnails_position READ extractVideoThumbnailsPosition WRITE setExtractVideoThumbnailsPosition NOTIFY extractVideoThumbnailsPositionChanged) + Q_PROPERTY(QString ffmpeg_executable READ ffmpegExecutable WRITE setFfmpegExecutable NOTIFY ffmpegExecutableChanged) public: GeneralSettingsObjectWrapper(QObject *parent); @@ -454,6 +457,9 @@ public: int o2Consumption() const; int pscrRatio() const; bool autoRecalculateThumbnails() const; + bool extractVideoThumbnails() const; + int extractVideoThumbnailsPosition() const; + QString ffmpegExecutable() const; public slots: void setDefaultFilename (const QString& value); @@ -464,6 +470,9 @@ public slots: void setO2Consumption (int value); void setPscrRatio (int value); void setAutoRecalculateThumbnails (bool value); + void setExtractVideoThumbnails (bool value); + void setExtractVideoThumbnailsPosition (int value); + void setFfmpegExecutable (const QString &value); signals: void defaultFilenameChanged(const QString& value); @@ -474,6 +483,9 @@ signals: void o2ConsumptionChanged(int value); void pscrRatioChanged(int value); void autoRecalculateThumbnailsChanged(int value); + void extractVideoThumbnailsChanged(bool value); + void extractVideoThumbnailsPositionChanged(int value); + void ffmpegExecutableChanged(const QString &value); private: const QString group = QStringLiteral("GeneralSettings"); }; |