Skip to content

Commit

Permalink
Use thumbnaild-video to generate video thumbnails
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvogt committed Sep 30, 2016
1 parent 93b6c1e commit 9695503
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 320 deletions.
12 changes: 0 additions & 12 deletions rpm/nemo-qml-plugin-thumbnailer-qt5.spec
Expand Up @@ -16,14 +16,6 @@ BuildRequires: oneshot
%description
%{summary}.

%package video
Summary: Video thumbnailer provider
Group: System/Libraries
Requires: %{name} = %{version}-%{release}

%description video
%{summary}.

%package devel
Summary: Thumbnail support for C++ applications
Group: System/Libraries
Expand Down Expand Up @@ -55,10 +47,6 @@ chmod +x %{buildroot}/%{_oneshotdir}/*
%{_libdir}/qt5/qml/org/nemomobile/thumbnailer/plugins.qmltypes
%{_oneshotdir}/remove-obsolete-nemothumbs-cache-dir

%files video
%defattr(-,root,root,-)
%{_libdir}/qt5/qml/org/nemomobile/thumbnailer/thumbnailers/libvideothumbnailer.so

%files devel
%defattr(-,root,root,-)
%{_libdir}/libnemothumbnailer-qt5.so
Expand Down
278 changes: 0 additions & 278 deletions src/gstvideothumbnailer/gstvideothumbnailer.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions src/gstvideothumbnailer/gstvideothumbnailer.pro

This file was deleted.

34 changes: 21 additions & 13 deletions src/lib/nemothumbnailcache.cpp
Expand Up @@ -43,6 +43,7 @@
#include <QtEndian>
#include <QElapsedTimer>
#include <QStandardPaths>
#include <QProcess>

#ifdef THUMBNAILER_DEBUG
#define TDEBUG qDebug
Expand Down Expand Up @@ -305,24 +306,31 @@ NemoThumbnailCache::ThumbnailData generateImageThumbnail(const QString &path, co
return NemoThumbnailCache::ThumbnailData();
}

typedef QImage (*CreateThumbnailFunc)(const QString &path, const QSize &requestedSize, bool crop);
QStringList generatorArgs(const QString &path, const QString &thumbnailPath, const QSize &requestedSize, bool crop)
{
QStringList args = {
QFile::encodeName(path),
"-w", QString::number(requestedSize.width()),
"-h", QString::number(requestedSize.height()),
"-o", QFile::encodeName(thumbnailPath)
};
if (crop) {
args.append("-c");
}

return args;
}

NemoThumbnailCache::ThumbnailData generateVideoThumbnail(const QString &path, const QByteArray &key, const QSize &requestedSize, bool crop)
{
static CreateThumbnailFunc createVideoThumbnail = (CreateThumbnailFunc)QLibrary::resolve(
QLatin1String(NEMO_THUMBNAILER_DIR "/libvideothumbnailer.so"), "createThumbnail");
const QString thumbnailPath(cachePath(key, true));

if (createVideoThumbnail) {
QImage img(createVideoThumbnail(path, requestedSize, crop));
if (!img.isNull()) {
const QString thumbnailPath(writeCacheFile(key, img));
TDEBUG() << Q_FUNC_INFO << "Wrote " << path << " to cache";
return NemoThumbnailCache::ThumbnailData(thumbnailPath, img, requestedSize.width());
} else {
TDEBUG() << Q_FUNC_INFO << "Could not createVideoThumbnail:" << path << requestedSize << crop;
}
int rv = QProcess::execute(QStringLiteral("/usr/bin/thumbnaild-video"), generatorArgs(path, thumbnailPath, requestedSize, crop));
if (rv == 0) {
TDEBUG() << Q_FUNC_INFO << "Wrote " << path << " to cache";
return NemoThumbnailCache::ThumbnailData(thumbnailPath, QImage(), requestedSize.width());
} else {
qWarning("Cannot generate video thumbnail, thumbnailer function not available.");
TDEBUG() << Q_FUNC_INFO << "Could not generateVideoThumbnail:" << path << requestedSize << crop;
}

return NemoThumbnailCache::ThumbnailData();
Expand Down
3 changes: 0 additions & 3 deletions src/src.pro
@@ -1,5 +1,2 @@
TEMPLATE = subdirs
SUBDIRS = lib plugin

packagesExist(gstreamer-0.10 gstreamer-app-0.10): SUBDIRS += gstvideothumbnailer
else: warning("gstreamer packages not available, video thumbnailing disabled")

0 comments on commit 9695503

Please sign in to comment.