summaryrefslogtreecommitdiffstats
path: root/helper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'helper.cpp')
-rw-r--r--helper.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/helper.cpp b/helper.cpp
index b73ea2a..1881102 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -19,9 +19,11 @@
#include <QProcess>
#include <QRect>
#include <QTime>
-#include <QtWidgets/QWidget>
-#include <QtWidgets/QDesktopWidget>
-#include <QtWidgets/QApplication>
+#include <QWidget>
+#include <QDesktopWidget>
+#include <QApplication>
+#include <QJsonDocument>
+#include <QJsonObject>
#include <stdio.h>
@@ -216,32 +218,22 @@ namespace Helper {
widget->move(widgetRect.topLeft());
}
- QList<QVariant> duration(const QString &path){
+
+ QVariantMap ffmpegData(const QString &path){
QSettings s;
QString ffProbe = s.value("paths/ffprobe").toString();
QStringList args;
- QList<QVariant> retval = QList<QVariant>() << QVariant() << QVariant();
- args << "-show_streams" << path;
+ QVariantMap retval;
+ args << "-v" << "quiet" << "-print_format" << "json" << "-show_format" << path;
QProcess ffproc;
ffproc.start(ffProbe, args);
if(!ffproc.waitForStarted()){
- return retval;
+ return QVariantMap();
}
ffproc.waitForFinished();
- QByteArray ffData = ffproc.readAllStandardError();
- QList<QByteArray> lines = ffData.split('\n');
-
- foreach(QString l, lines){
- QString llc = l.toLower();
- if(llc.contains("duration")){
- int idx = llc.indexOf("duration:");
- retval[0].setValue(Duration(llc.mid(idx + 10, 8)));
- idx = llc.indexOf("bitrate:");
- retval[1] = llc.mid(idx + 9);
- break;
- }
- }
- return retval;
+ QByteArray ffData = ffproc.readAllStandardOutput();
+ QJsonDocument jsDoc = QJsonDocument::fromJson(ffData);
+ return jsDoc.object().value("format").toObject().toVariantMap();
}
Duration::Duration() : mHours(0), mMinutes(0), mSeconds(0) {}
@@ -249,7 +241,7 @@ namespace Helper {
Duration::Duration(qint64 seconds){
int sec(0), min(0), h(0);
// get hours
- h = (seconds / 60 / 60) % 24;
+ h = (seconds / 60 / 60);
// remaining minutes
min = (seconds / 60) % 60;
// seconds