Bug 315323 - Allow to create Time Lapse in digiKam
Summary: Allow to create Time Lapse in digiKam
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-VideoSlideshow (show other bugs)
Version: 5.5.0
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-17 14:45 UTC by Vangelis
Modified: 2024-01-15 22:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.3.0


Attachments
Perl Deflickering Script (5.89 KB, application/x-perl)
2013-02-17 14:47 UTC, Vangelis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vangelis 2013-02-17 14:45:02 UTC
One feature I really miss from Linux and not only digikam itself, is the ability to create time lapse videos from photographs easily.

After some intensive search and work, I found my way to create time lapse videos, but I need the console and a few manual steps that probably would be easy to be implemented as a new feature in digikam (probably by a Google Summer of Code project assigned to a student? :) ).

Step 1:
First you need to put all of the pictures in a folder that you will work with (In digikam you should get a window with some options on either to choose the photos one by one, or a folder and all of its contained images).

Step 2:
You need create a text file and put the filenames in the right frame order and sometimes when the time your camera reaches the final file like DSC_9999.jpg, it will start from DSC_0001.jpg again so this might not be trivial in specific cases. So digikam should read the exif an put the photographs in order according to their creation date.

Step 3:
The photographs must be resized to the desired output video resolution. For example if you want to create a FullHD 1920x1080 video, but your photos are 18Mpixels, first you need to resize the pictures otherwise you will get much unnecessary processing time. The plugin should give the option to the user to keep the aspect ration or not.

Step 4:
Optionally you might want change the levels, brightness, contrast, saturation, curves or sharpen all of the photographs to promote some details and enhance the photos, so some batch processing should be done here similar to the recording functionality of Photoshop but much simpler. Ideally open the first photo in showfoto, make some limited changes, and perform these to the rest of the photos being part of the time lapse

Step 5:
The photographs will usually have some flickering because even if you choose a fixed shutter speed, this might not be exact for each photograph taken, due to the mechanical parts of the camera (If 1/200s is chosen as the shutter speed, first photo might 1/199s and the one after might 1/202s). In this case the final time lapse video will be flickered. Optional deflickering with some options chosen by the user (for example the rolling window averages for luminance calculation for each photo) should take process.

Step 6:
Create a quick preview of the video and show it to the user.

Step 7:
Choose the codec to compile the time lapse video and save it.

This would give much value to digikam, and the whole open source Linux world as I haven't found a tool to perform these simple tasks with a nice graphical user interface.

The way I perform these steps now is the following:

Resize the images first to 1920x1080 (all of the rest of the operations will be much much faster)

Resize pictures:
# cd source_folder_of_pictures
# mkdir resized
# mogrify -path resized -resize 1920x1080! *.jpg

Use ls to sort the files by their filename.
# cd resized
# ls -1 | grep -v files.txt > files.txt

Use mencoder to combine all of the photos in one video without losing quality!
WARNING: Use ONLY ONE of the following 3 commands
TIP: I usually choose the first one to quickly check the result and then I re-make the video with the second or third command if I want to make some post processing in kdenlive.

Command 1 # mencoder -nosound -noskip -oac copy -ovc copy -o test.avi -mf fps=15 'mf://@files.txt' <- Very fast but does not create index so if you want to edit with a non linear editor do not choose this.

Command 2 # mencoder -idx -nosound -noskip -ovc lavc -lavcopts vcodec=mjpeg -o test.avi -mf fps=25 'mf://@files.txt' <- Fast, it will create index, but it will re-compress the JPG files so some loss of quality will occur (insignificant, so you can safely bet on this) 

Command 3 # mencoder -idx -nosound -noskip -ovc lavc -lavcopts vcodec=ljpeg -o test.avi -mf fps=25 'mf://@files.txt' <- Slow, it will create index, it will re-compress the JPG file but with the highest quality options to provide lossless results (the final file will be larger than the total of the original files, but if you are a quality freak, then go for this one)


Use ffmpeg to compress the video.
# avconv -i test.avi -c:v libx264 -preset slow -crf 15 output-final.mkv

Check here for more encoding options: https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide

To perform the two optional steps:
Step 4: I use photoshop in wine and the record functionality
Step 5: I have made my own perl script that uses imagemagick to calculate luminance of each photo, calculate the new luminance for each photo with rolling averages and eventually change the luminance for each photo (https://www.youtube.com/watch?v=SNfq__chC5M).

Reproducible: Always
Comment 1 Vangelis 2013-02-17 14:47:13 UTC
Created attachment 77380 [details]
Perl Deflickering Script
Comment 2 caulier.gilles 2013-02-17 16:51:10 UTC
digiKam 3.0.0 has a video slideshow generator...

Gilles Caulier
Comment 3 caulier.gilles 2013-02-17 17:24:33 UTC
http://community.kde.org/Digikam/GSoC2012#Video_Slide_Show_Generator

Gilles Caulier
Comment 4 Vangelis 2013-02-17 18:34:20 UTC
This plugin could use much of the video slideshow generator code but I think it should be a different plugin because time lapse needs are totally different than these of a slideshow. For example you don't want any transition effects, but you need deflickering most of the times and batch editing of the source photographs (Steps 4 and 5 that I described above).
Also you need to be able to set the framerate of the final video (for example 25fps) instead of setting how much time each of the slides will be presented for. The video slideshow generator will not let you show a picture for less than 1 second so this is only 1fps which is not enough for a time lapse video.
Comment 5 caulier.gilles 2013-02-17 19:02:51 UTC
No. A new plugin is not necessary, but an improvement of current one must be done...

Gilles Caulier
Comment 6 Vangelis 2013-02-17 19:06:11 UTC
(In reply to comment #5)
> No. A new plugin is not necessary, but an improvement of current one must be
> done...
> 
> Gilles Caulier

Then I agree :)
Comment 7 caulier.gilles 2024-01-09 12:37:35 UTC
Hi,

To test the Video SlideShow tool with the de-flickering feature, can you provide a set of images as tarball captured without correction.

Thanks in advance

Gilles Caulier
Comment 8 Vangelis 2024-01-14 19:17:46 UTC
Sure, Gilles,

You can download the pictures from this timelapse: https://www.youtube.com/watch?v=nEBFQj8oid0

from here: https://www.dropbox.com/scl/fi/45a1r6eeoxtctonfrornx/digikam-bug-315323.tar?rlkey=l8j4toe9wld093pxtq1fyeecv&dl=0

Vangelis
Comment 9 caulier.gilles 2024-01-15 07:12:50 UTC
Hi Vangelis,

First thanks for the timelapse data. I can create easily the same video as you (and yes, i can encode one image by frame without problem). I can confirm the non normalization of luminosity. 

The new VideoSlideshow plugin use ffmpeg, where filters can be applied while encoding as this one:

https://ffmpeg.org/ffmpeg-filters.html#normalize

Best

Gilles Caulier
Comment 10 caulier.gilles 2024-01-15 08:18:01 UTC
Git commit 562a9c8b749a68ee3d9d3ee88763b17dc07ce7dd by Gilles Caulier.
Committed on 15/01/2024 at 09:16.
Pushed by cgilles into branch 'master'.

add FFmpeg normalize filter to applying while encoding video from frames

M  +12   -0    core/libs/video/manager/ffmpeglauncher.cpp

https://invent.kde.org/graphics/digikam/-/commit/562a9c8b749a68ee3d9d3ee88763b17dc07ce7dd
Comment 11 caulier.gilles 2024-01-15 08:41:35 UTC
Git commit 50c2e99e560be4de22417ed1207f4ac90d11569d by Gilles Caulier.
Committed on 15/01/2024 at 09:43.
Pushed by cgilles into branch 'master'.

add Norlize and Smoothing FFmpeg settings for future luminosity equalization while encoding frames from a timelapse.

M  +9    -1    core/libs/video/manager/vidslidesettings.cpp
M  +2    -0    core/libs/video/manager/vidslidesettings.h

https://invent.kde.org/graphics/digikam/-/commit/50c2e99e560be4de22417ed1207f4ac90d11569d
Comment 12 caulier.gilles 2024-01-15 08:45:05 UTC
Git commit 9049e9e78c39bc0e1d14376c44f9656412d6210b by Gilles Caulier.
Committed on 15/01/2024 at 09:47.
Pushed by cgilles into branch 'master'.

pass normalize and smoothing settings to the FFmpeg CLI

M  +6    -2    core/libs/video/manager/ffmpeglauncher.cpp

https://invent.kde.org/graphics/digikam/-/commit/9049e9e78c39bc0e1d14376c44f9656412d6210b
Comment 13 caulier.gilles 2024-01-15 12:39:19 UTC
Git commit 085c1b70aba8d220da4f536c53c48b8ea81ef296 by Gilles Caulier.
Committed on 15/01/2024 at 13:40.
Pushed by cgilles into branch 'master'.

Finalize the equalize luminosity encoding frames with FFmpeg while creating timelapse.
FIXED-IN: 8.3.0

M  +2    -2    NEWS
M  +0    -6    core/dplugins/generic/tools/videoslideshow/wizard/vidslidefinalpage.cpp
M  +52   -15   core/dplugins/generic/tools/videoslideshow/wizard/vidslideoutputpage.cpp
M  +5    -5    core/libs/video/manager/ffmpeglauncher.cpp
M  +7    -7    core/libs/video/manager/vidslidesettings.cpp
M  +2    -2    core/libs/video/manager/vidslidesettings.h

https://invent.kde.org/graphics/digikam/-/commit/085c1b70aba8d220da4f536c53c48b8ea81ef296
Comment 14 caulier.gilles 2024-01-15 13:41:16 UTC
Vangelis,

This is the resulting video timelapse generated with your images:

https://i.imgur.com/5G4vBq8.mp4

Gilles Caulier
Comment 15 caulier.gilles 2024-01-15 13:47:39 UTC
Screenshots of the VlideSlideShow tool in action to generate your timelapse video:

https://i.imgur.com/IJgp8dJ.png
https://i.imgur.com/jROyOom.png
https://i.imgur.com/XeQg8fD.png
https://i.imgur.com/0N6mkBP.png
https://i.imgur.com/Twd3MpF.png
https://i.imgur.com/3ZWtoxr.png

Gilles Caulier
Comment 16 Vangelis 2024-01-15 22:18:11 UTC
This is Awesome!

Thanks a lot for adding this feature Gilles!