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 --- .../preferences/preferences_defaults.cpp | 27 ++++++++ desktop-widgets/preferences/preferences_defaults.h | 2 + .../preferences/preferences_defaults.ui | 75 +++++++++++++++++++++- 3 files changed, 103 insertions(+), 1 deletion(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp index a7b5e4c1d..4d8aef610 100644 --- a/desktop-widgets/preferences/preferences_defaults.cpp +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -43,6 +43,22 @@ void PreferencesDefaults::on_localDefaultFile_toggled(bool toggle) ui->chooseFile->setEnabled(toggle); } +void PreferencesDefaults::on_ffmpegFile_clicked() +{ + QFileInfo fi(system_default_filename()); + QString ffmpegFileName = QFileDialog::getOpenFileName(this, tr("Select ffmpeg executable")); + + if (!ffmpegFileName.isEmpty()) + ui->ffmpegExecutable->setText(ffmpegFileName); +} + +void PreferencesDefaults::on_extractVideoThumbnails_toggled(bool toggled) +{ + ui->videoThumbnailPosition->setEnabled(toggled); + ui->ffmpegExecutable->setEnabled(toggled); + ui->ffmpegFile->setEnabled(toggled); +} + void PreferencesDefaults::refreshSettings() { ui->font->setCurrentFont(QString(prefs.divelist_font)); @@ -73,6 +89,14 @@ void PreferencesDefaults::refreshSettings() ui->defaultfilename->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); ui->btnUseDefaultFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); ui->chooseFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); + + ui->videoThumbnailPosition->setEnabled(prefs.extract_video_thumbnails); + ui->ffmpegExecutable->setEnabled(prefs.extract_video_thumbnails); + ui->ffmpegFile->setEnabled(prefs.extract_video_thumbnails); + + ui->extractVideoThumbnails->setChecked(prefs.extract_video_thumbnails); + ui->videoThumbnailPosition->setValue(prefs.extract_video_thumbnails_position); + ui->ffmpegExecutable->setText(prefs.ffmpeg_executable); } void PreferencesDefaults::syncSettings() @@ -87,6 +111,9 @@ void PreferencesDefaults::syncSettings() general->setDefaultFileBehavior(LOCAL_DEFAULT_FILE); else if (ui->cloudDefaultFile->isChecked()) general->setDefaultFileBehavior(CLOUD_DEFAULT_FILE); + general->setExtractVideoThumbnails(ui->extractVideoThumbnails->isChecked()); + general->setExtractVideoThumbnailsPosition(ui->videoThumbnailPosition->value()); + general->setFfmpegExecutable(ui->ffmpegExecutable->text()); auto display = qPrefDisplay::instance(); display->set_divelist_font(ui->font->currentFont().toString()); diff --git a/desktop-widgets/preferences/preferences_defaults.h b/desktop-widgets/preferences/preferences_defaults.h index 1674dd2ad..d7bb7db7f 100644 --- a/desktop-widgets/preferences/preferences_defaults.h +++ b/desktop-widgets/preferences/preferences_defaults.h @@ -20,6 +20,8 @@ public slots: void on_chooseFile_clicked(); void on_btnUseDefaultFile_toggled(bool toggled); void on_localDefaultFile_toggled(bool toggled); + void on_ffmpegFile_clicked(); + void on_extractVideoThumbnails_toggled(bool toggled); private: Ui::PreferencesDefaults *ui; diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui index 1a54d7b0a..731eed6ab 100644 --- a/desktop-widgets/preferences/preferences_defaults.ui +++ b/desktop-widgets/preferences/preferences_defaults.ui @@ -73,7 +73,7 @@ - No default file + &No default file @@ -209,6 +209,79 @@ + + + + Video thumbnails + + + + 5 + + + 5 + + + 5 + + + + + ffmpeg executable + + + + + + + + + + + + ... + + + + + + + + + Extract at position + + + + + + + 100 + + + 20 + + + Qt::Horizontal + + + + + + + Extract video thumbnails + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2