summaryrefslogtreecommitdiffstats
path: root/helper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'helper.cpp')
-rw-r--r--helper.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/helper.cpp b/helper.cpp
index b3f2fc6..cfb1711 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -18,6 +18,7 @@
#include <QTemporaryFile>
#include <QProcess>
#include <QRect>
+#include <QTime>
#include <QtWidgets/QWidget>
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QApplication>
@@ -208,5 +209,33 @@ namespace Helper {
widgetRect.moveCenter(qApp->desktop()->screenGeometry(widget).center());
widget->move(widgetRect.topLeft());
}
+
+ QList<QVariant> duration(const QString &path){
+ QSettings s;
+ QString ffProbe = s.value("paths/ffprobe").toString();
+ QStringList args;
+ QList<QVariant> retval;
+ args << "-show_streams" << path;
+ QProcess ffproc;
+ ffproc.start(ffProbe, args);
+ if(!ffproc.waitForStarted()){
+ return retval;
+ }
+ 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 << llc.mid(idx + 10, 8);
+ idx = llc.indexOf("bitrate:");
+ retval << llc.mid(idx + 9);
+ break;
+ }
+ }
+ return retval;
+ }
}