Now that there is a set of usable, illuminated images, they can be stitched together to make a timelapse movie. There are numerous ways to accomplish this, but the methods chosen here use only free software, and work on Windows. The basic workflow is as follows:
A) Rename files
This was not originally a part of the workflow, but there were two issues: one, the timestamp software did not like the colon characters in the time stamp, and the timelapse video software reads files with a simple wildcard, causing the images to be sorted out of order. Here, scripts were put together to simply sort and rename the files.
The renaming code (batch_rename.py) is designed primarily to remove special characters (i.e, transform ‘2018-02-05_20:40:01.jpg’ to ‘20180205204001.jpg’) but has the option to sequentially renumber the files based upon a defined range (i.e., 600 images would start at ‘001’ and end at ‘600’.) The files are sorted using Python’s built-in sorted() algorithm.
Additionally, images can be picked from a range of hours in a day (daily_subset_and_rename.py), which also calls batch_rename.py to scrub or renumber the final output. This is useful for some timelapse images where light varies throughout the day, so having the same times of day is more consistent.
FastStone Image Viewer is free software that can be used to place a timestamp in each image. The software used to capture the images, fswebcam, has a “banner” option where a time stamp could be added; however, the override settings did not work in this instance, and was disabled during image capture. Once the software is installed, here is how to add a timestamp:
- Navigate to directory containing renamed images
- Select all images
- Tools > Batch Convert Selected Images (F3)
- Check “Use Advanced Options”
- Advanced Options > Text
- For “YYYY-MM-DD”, use “($H2)-($H3)-($H4)”
- Set the font size as desired (36-point used here)
- Set position (Bottom-Right used here)
- Explore other tabs in Advanced Options. A systematic crop (Crop tab) or watermark (Watermark tab) can be added, for example
- Output Format > Settings
- Make sure full image quality is preserved, unless compression is desired
- Set Output Folder to a new folder (this avoids accidental overwrite
- Once all options are selected, click Convert to start processing
C) Create timelapse video
The cross-platform command line software FFMPEG is used to create the timelapse video. There are lots of options that can be used for this software; a good walkthrough of FFMPEG for timelapse videos is here. Here, the following command is used to create the video:
C:\Users\USERNAME\Downloads\ffmpeg.exe -r 90 -start_number 0001 -i %4d.jpg -vcodec libx264 -threads 4 90fps.mp4
A breakdown of the command:
C:\Users\USERNAME\Downloads\ffmpeg.exespecifies the path to the executable. This instance of FFMPEG is not installable, so it is called from the Downloads directory.
-r 90specifies the frames per second (fps), set to 90 here.
-start_number 0001tells FFMPEG where to start in file sequence.
-i %4d.jpgspecifies input filename, using expression
%4dto say there’s four digits in the file string, with the extension .jpg following immediately after.
-vcodec libx264specifies the video codec. The Windows builds of FFMPEG should have this codec enabled by default.
-threads 4specifies the number of processing threads to be used.
90fps.mp4Output file, with extension. This will save the file in the current directory, which can be checked using
cdin the Windows command line.
A video composed of 1,139 images took about 3 minutes to run using 4 threads in FFMPEG. Only images captured between 10 am and 2 pm each day were used. There were intermittent camera downtimes, causing jumps towards the end of the video. An auxiliary water reservoir was added later, but malfunctioned, causing the plant to wilt; however, it was nursed back to health with some string and constant water supply. Here is the final product:
Also note the progress of the avocado plant, which has grown rapidly after it initially sprouted!