[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/multimedia/mplayerthumbs/src
From: Marco Gulino <marco () kmobiletools ! org>
Date: 2008-07-11 21:45:21
Message-ID: 1215812721.442541.10154.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 831118 by gulino:
Try having a better behaviour on multiple calls.
M +18 -6 videopreview.cpp
M +1 -0 videopreview.h
--- trunk/playground/multimedia/mplayerthumbs/src/videopreview.cpp #831117:831118
@@ -39,6 +39,7 @@
#include <kurl.h>
#include <math.h>
#include <qfileinfo.h>
+#include <kcodecs.h>
#include "mplayerthumbs.h"
@@ -70,6 +71,7 @@
}
bool VideoPreview::startAndWaitProcess(const QStringList &args) {
+ kDebug(DBG_AREA) << "videopreview: starting process with args: " << args << \
endl; mplayerprocess->start( args.join(" ") );
if(! mplayerprocess->waitForStarted() ) {
kDebug(DBG_AREA) << "videopreview: PROCESS NOT STARTED!!! exiting\n";
@@ -116,6 +118,7 @@
fileinfo.fps=0;
tmpdir=new KTempDir();
if(tmpdir->name().isNull() ) return false;
+ kDebug(DBG_AREA) << "videopreview: using temp directory " << tmpdir->name() << \
endl;
rand=new KRandomSequence(QDateTime::currentDateTime().toTime_t());
mplayerprocess=new QProcess();
@@ -165,7 +168,7 @@
}
if(pix.isNull() )
{
- if(tmpdir) tmpdir->unlink();
+ tryUnlink(tmpdir);
return false;
}
/** From videocreator.cpp - xine_artsplugin
@@ -194,10 +197,14 @@
//#endif
img = pix.toImage();
- if(tmpdir) tmpdir->unlink();
+ tryUnlink(tmpdir);
return true;
}
+void VideoPreview::tryUnlink(KTempDir *dir) {
+ if(dir) dir->unlink();
+}
+
QPixmap VideoPreview::getFrame(const QString &path, int flags)
{
QStringList args;
@@ -228,17 +235,22 @@
// If we can't skip to a random frame, let's try playing 10 seconds.
args << "-frames" << QString::number( fileinfo.fps*10 );
}
+ KMD5 md5builder(path.toLatin1() );
+ QString md5file=md5builder.hexDigest().data();
+ QString tmpDirPath = tmpdir->name() + md5file + QDir::separator();
args << "-nocache" << "-idx" /*@TODO check if it's too slow..*/ << "-ao" << \
"null"/*"-nosound" << */<< "-speed" << "99" /*<< "-sstep" << "5"*/
- << "-vo" << QString("jpeg:outdir=%1").arg(tmpdir->name() ) << "-vf" << \
QString("scale=%1:%2").arg(fileinfo.towidth).arg(fileinfo.toheight); + << \
"-vo" << QString("jpeg:outdir=%1").arg(tmpDirPath ) << "-vf" << \
QString("scale=%1:%2").arg(fileinfo.towidth).arg(fileinfo.toheight); \
args+=customargs;
if (! startAndWaitProcess(args) ) return NULL;
- if (QDir(tmpdir->name() ).entryList( QStringList("*.jpg") ).isEmpty() ) return \
false; + kDebug(DBG_AREA) << "videopreview: temp dir '" << tmpDirPath << "'\n";
- QString lastframe=QDir(tmpdir->name() ).entryList( QStringList("*.jpg") \
).last(); + if (QDir(tmpDirPath ).entryList( QStringList("*.jpg") ).isEmpty() ) \
return false; +
+ QString lastframe=QDir(tmpDirPath ).entryList( QStringList("*.jpg") ).last();
kDebug(DBG_AREA) << "videopreview: LastFrame==" << lastframe << endl;
- QPixmap retpix(tmpdir->name().append( lastframe ));
+ QPixmap retpix(tmpDirPath.append( lastframe ));
return retpix;
}
--- trunk/playground/multimedia/mplayerthumbs/src/videopreview.h #831117:831118
@@ -47,6 +47,7 @@
protected:
QPixmap getFrame(const QString &path, int flags);
static uint imageVariance(QImage image );
+ void tryUnlink(KTempDir *dir);
private:
char *m_data;
int m_dataSize;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic