diff --git a/qml/pages/FileDelegate.qml b/qml/pages/FileDelegate.qml index f7c4a6d..ab986dd 100644 --- a/qml/pages/FileDelegate.qml +++ b/qml/pages/FileDelegate.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import FileCase 1.0 -import org.nemomobile.thumbnailer 1.0 +import Nemo.Thumbnailer 1.0 ListItem { diff --git a/qml/pages/FileInfo.qml b/qml/pages/FileInfo.qml index 11b64c1..eb02b71 100644 --- a/qml/pages/FileInfo.qml +++ b/qml/pages/FileInfo.qml @@ -1,8 +1,8 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import FileCase 1.0 -import org.nemomobile.thumbnailer 1.0 import QtMultimedia 5.0 +import Nemo.Thumbnailer 1.0 Page { id: infoPage @@ -108,7 +108,7 @@ Page { MenuItem { text: isPackage && !cloudFile? qsTr("Install") : qsTr("Open") visible: !cloudFile && !isTextFile - onClicked: utilities.openFile(fileInfo.data.path + "/" + fileInfo.data.name) + onClicked: Qt.openUrlExternally(fileInfo.data.path + "/" + fileInfo.data.name) } MenuItem { diff --git a/src/thumbgenerator.cpp b/src/thumbgenerator.cpp index 8ad50cf..f6aa691 100644 --- a/src/thumbgenerator.cpp +++ b/src/thumbgenerator.cpp @@ -9,7 +9,7 @@ #include #include #include - +#include #include typedef QImage (*CreateThumbnailFunc)(const QString &fileName, const QSize &requestedSize, bool crop); @@ -94,28 +94,31 @@ void ThumbGenerator::generate(QString filename) file.replace("#","%2523"); file.replace(",","%2C"); file.replace(" ","%20"); - file = "file://"+file; + file = "file://" + file; md.addData(file.toUtf8()); - QString tf = Config::getHome() + "/.thumbnails/whatsup/"+ QString(md.result().toHex().constData()) + ".jpeg"; + QString tf = Config::getHome() + "/.thumbnails/whatsup/" + QString(md.result().toHex().constData()) + ".jpeg"; thumb = tf; - if ( !QFileInfo(tf).exists() ) + if (!QFileInfo(thumb).exists()) { - //Utilities::logData("Generating video thumbnail for " + fileInfo.absoluteFilePath()); - //VideoThumbnailer *thumbnailer = new VideoThumbnailer; - //QImage result = thumbnailer->createThumbnail(filename.remove("file://"), QSize(170,170), true); - QImage image; - - static CreateThumbnailFunc createThumbnail = (CreateThumbnailFunc)QLibrary::resolve( - QLatin1String("/usr/lib/qt5/qml/org/nemomobile/thumbnailer/thumbnailers/libvideothumbnailer.so"), "createThumbnail"); - - if (createThumbnail) { - image = createThumbnail(filename, QSize(800,800), false); + QString command = "ffmpeg"; //used to replace "/usr/lib/qt5/qml/org/nemomobile/thumbnailer/thumbnailers/libvideothumbnailer.so" solution + QStringList arguments; + arguments << "-i" << fileInfo.absoluteFilePath() + << "-ss" << "00:00:01" // Arbitrary time can be anything (1 second here) + << "-vframes" << "1" + << "-q:v" << "2" // Quality factor. Lower is better. Higher gives lower bitrate. 2 is 1735 kb/s Check https://ffmpeg.org/ffmpeg-codecs.html#Options-22 + << thumb; + + QProcess process; + process.start(command, arguments); + process.waitForFinished(); + + if (process.exitCode() != 0) { + //Need to test what might go wrong..should add .close() + qDebug() << "ffmpeg ERROR: " << file; } - - image.save( tf, "JPEG" ); } - emit imgLoaded(tf); + emit imgLoaded(thumb); } imagesToProcess.removeAt(0); diff --git a/src/utilities.cpp b/src/utilities.cpp index 4ea9f77..dafb0e3 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -76,6 +76,7 @@ void Utilities::removeFromBookmarks(QString folder) void Utilities::openFile(QString file) { + //This is no longer needed since we will be using Qt.openUrlExternally keeping it here untill final testing QProcess * process = new QProcess(); process->start(QString("xdg-open \"%2\"").arg(file));