[KPhotoAlbum] speeding up video thumbnail generation
Andreas Schleth
schleth_es at web.de
Mon Sep 4 00:19:11 BST 2017
Hi,
I was trying to use KPA for managing a collection of longish video files
and found thumbnail generation extremely slow (with ffmpeg).
However, there is an easy fix: move the -ss parameter in front of the -i
parameter:
change Lines 69ff in ImageManager/ExtractOneVideoFrame.cpp to:
arguments << STR("-ss") << QString::number(offset,'f',4) <<
STR("-i") << fileName.absolute()
<< STR("-sn") << STR("-an")
<< STR("-vframes") << STR("20")
<< m_workingDirectory + STR("/000000%02d.png");
Even for videos of 2h runtime this is speedy.
The difference between the -ss up front and the -ss after -i is:
With the option up front ffmpeg searches the file to the approximate
position and then starts decoding. Searching (jumping to a position) a
file is fast.
With the option in the back the file gets decoded up to this position
and then the thumbs are generated. Thus, the whole file would be decoded
5 times for 10 thumbnail frames.
This change would make the positions less precise, but in this case
precsion would be overrated.
Best regards, Andreas
PS: this is the output of git diff (is this of any use?):
diff --git a/ImageManager/ExtractOneVideoFrame.cpp
b/ImageManager/ExtractOneVideoFrame.cpp
index 3ce0d78c..a5a4242e 100644
--- a/ImageManager/ExtractOneVideoFrame.cpp
+++ b/ImageManager/ExtractOneVideoFrame.cpp
@@ -66,8 +66,8 @@ ExtractOneVideoFrame::ExtractOneVideoFrame(const
DB::FileName &fileName, double
m_process->start(MainWindow::FeatureDialog::mplayerBinary(), arguments);
} else {
QStringList arguments;
- arguments << STR("-i") << fileName.absolute()
- << STR("-sn") << STR("-an") << STR("-ss") <<
QString::number(offset,'f',4)
+ arguments << STR("-ss") << QString::number(offset,'f',4) <<
STR("-i") << fileName.absolute()
+ << STR("-sn") << STR("-an")
<< STR("-vframes") << STR("20")
<< m_workingDirectory + STR("/000000%02d.png");
//qDebug( "%s %s",
qPrintable(MainWindow::FeatureDialog::ffmpegBinary()),
qPrintable(arguments.join(QString::fromLatin1(" "))));
More information about the Kphotoalbum
mailing list