[KPhotoAlbum] speeding up video thumbnail generation

Tobias Leupold tobias.leupold at gmx.de
Mon Sep 4 10:05:04 CEST 2017


Hi Andreas!

Thanks for the patch! I just comitted it.

Git diffs are always useful, but please send the patch file as an attachment 
so that the formatting (line breaks etc.) is not lost. No problem in this 
small case however ;-)

Cheers, Tobias

Am Montag, 4. September 2017, 01:19:11 CEST schrieb Andreas Schleth:
> 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(" "))));
> _______________________________________________
> KPhotoAlbum mailing list
> KPhotoAlbum at mail.kdab.com
> https://mail.kdab.com/mailman/listinfo/kphotoalbum




More information about the KPhotoAlbum mailing list