diff options
Diffstat (limited to 'helper.cpp')
-rw-r--r-- | helper.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -14,6 +14,9 @@ #include <QHash> #include <QSettings> #include <QDir> +#include <QPixmap> +#include <QTemporaryFile> +#include <QProcess> #include <stdio.h> @@ -149,7 +152,7 @@ namespace Helper { return qMakePair(programData.value("path").toString(), programData.value("args").toStringList()); } - QString durationFromSecs(qint64 secs){ + const QString durationFromSecs(qint64 secs){ int minutes = secs / 60; int hours = 0; int seconds = 0; @@ -164,6 +167,27 @@ namespace Helper { return retval; } + const QPixmap grabFrame(const QString &file, QString when){ + QSettings s; + QString ffMpegPath = s.value("paths/ffmpeg").toString(); + if(when.isEmpty()){ + when = s.value("ui/grabframe", "00:00:00").toString(); + } + QString tmptmp = QString("%1/smhover-XXXXXX.png").arg(QDir::tempPath()); + QTemporaryFile tmpPic(tmptmp); + if(tmpPic.open()){ + QStringList ffMpegArgs = QStringList() << "-vframes" << "1" << "-ss" << when << "-i" << file << "-y" << tmpPic.fileName(); + QProcess ffmpeg; + ffmpeg.start(ffMpegPath, ffMpegArgs); + if(!ffmpeg.waitForStarted()){ + return QPixmap(); + } + ffmpeg.waitForFinished(); + return QPixmap(tmpPic.fileName()); + } + return QPixmap(); + } + bool SortFileInfoList::operator ()(const QFileInfo &lhs, const QFileInfo &rhs) const { return lhs.fileName().toLower() < rhs.fileName().toLower(); } |