Idea is to have motion monitoring the space and when event starts a python daemon to handle capturing the timelapse photos is started. Strictly speaking this part is an intervalometer.
Another process (running on a network server, where the photos will be stored, conserve write cycles on the SD card) will then convert these photos into a time lapse movie.
mkdir resized
mogrify -path resized/ -resize x1080 `find . -name '*.jpg'`
cd resized
cat *.jpg | ffmpeg -f image2pipe -r 5 -vcodec mjpeg -i - -vcodec libx264 -movflags faststart out.mp4
mkdir resized
mogrify -path resized/ -resize x1080 -gravity southwest -stroke '#000C' -strokewidth 5 -annotate 0 '%t' -stroke none -fill white -annotate 0 '%t' `find . -name '*.jpg'`
And if you do not have RTC on the computer you are using you might get weird timestamps, use timestamp_adjust.py to fix the names and timedelta_calc.py to calculate the adjust values.
Use GNU Parallel.
mkdir resized
find . -name '*.jpg' | parallel mogrify -path resized/ -resize x1080 -gravity southwest -stroke '\#000C' -strokewidth 5 -annotate 0 '%t' -stroke none -fill white -annotate 0 '%t'
understand the perl-script and either incorporate it to the helpers or rewrite in python.
Sometimes we lose a chunk of time, make a script to recognize this and add "camera lost" images with suitable timestamps to keep consistent flow of time.
Losing a few frames is not bad but an hour worth of frames is.