setup for adding thumbnails from videos

This commit is contained in:
Chris Cochrun 2023-02-07 10:55:23 -06:00
parent 6366dc2d88
commit fb9d551f6b
3 changed files with 26 additions and 11 deletions

View file

@ -543,12 +543,6 @@ void MpvObject::loadFile(QVariant urls)
} }
void MpvObject::screenshotToFile(QUrl url) { void MpvObject::screenshotToFile(QUrl url) {
qDebug() << "Url of screenshot to be taken: " << url;
QDir dir = writeDir.absolutePath() + "/presenter/Church Presenter/thumbnails";
qDebug() << "thumbnails dir: " << dir;
QDir absDir = writeDir.absolutePath() + "/presenter/Church Presenter";
if (!dir.exists())
absDir.mkdir("thumbnails");
QString file = url.path() + ".jpg"; QString file = url.path() + ".jpg";
commandAsync(QVariantList() << "screenshot-to-file" << file << "video"); commandAsync(QVariantList() << "screenshot-to-file" << file << "video");
} }

View file

@ -20,6 +20,8 @@
#include <iostream> #include <iostream>
const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
SlideModel::SlideModel(QObject *parent) SlideModel::SlideModel(QObject *parent)
: QAbstractListModel(parent) { : QAbstractListModel(parent) {
// if () { // if () {
@ -641,14 +643,33 @@ void SlideModel::moveRowFromService(const int &fromIndex,
} }
} }
QString SlideModel::thumbnailVideo(QString video) { QString SlideModel::thumbnailVideo(QString video, int serviceItemId) {
std::system("ffmpeg -i Rust\ Tutorial\ Full\ Course.webm -vframes 1 -an -s 576x324 -ss 35 OutputFile.jpg"); // if (!writeDir.mkpath(".")) {
// qFatal("Failed to create writable location at %s", qPrintable(writeDir.absolutePath()));
// }
QTemporaryFile thumbnail; // qDebug() << "Url of screenshot to be taken: " << url;
// QDir dir = writeDir.absolutePath() + "/thumbnails";
// qDebug() << "thumbnails dir: " << dir;
// QDir absDir = writeDir.absolutePath();
// if (!dir.exists())
// absDir.mkdir("thumbnails");
QTemporaryFile thumbnail = ;
if (thumbnail.open()) { if (thumbnail.open()) {
qDebug() << "@@@@@@@@@@@@@@@@@@@@@";
qDebug() << thumbnail.fileName();
qDebug() << "@@@@@@@@@@@@@@@@@@@@@";
return thumbnail.fileName(); // return thumbnail.fileName();
} }
QTemporaryDir dir;
if (dir.isValid()) {
// dir.path() returns the unique directory path
qDebug() << "@@@@@@@@@@@@@@@@@@@@@";
qDebug() << dir.path();
qDebug() << "@@@@@@@@@@@@@@@@@@@@@";
}
} }

View file

@ -79,7 +79,7 @@ public:
Q_INVOKABLE QVariantMap getItem(int index) const; Q_INVOKABLE QVariantMap getItem(int index) const;
Q_INVOKABLE QVariantList getItems(); Q_INVOKABLE QVariantList getItems();
Q_INVOKABLE int findSlideIdFromServItm(int index); Q_INVOKABLE int findSlideIdFromServItm(int index);
Q_INVOKABLE void thumbnailVideo(QString video); Q_INVOKABLE void thumbnailVideo(QString video, int serviceItemId);
public slots: public slots: