Last update 20210609

Last update 20210714

I have a time-lapse with over 20k of images and any program I use crashes or grinds to a halt at the slightest interface click.

I've tried using adobe premier pro took over 4 mins for every click.

I've tried a custom program I found on line but its super inflexible.

Here I gave in and I'm trying using the dreaded dragon that is


Creating a Time-Lapse Video Through the Command-Line (Using FFmpeg)

ffmpeg -framerate 30 -pattern_type glob -i "folder-with-photos/*.JPG" -s:v 1440x1080 -c:v libx264 -crf 17 -pix_fmt yuv420p my-timelapse.mp4

my version

ffmpeg -framerate 30 -pattern_type glob -i "*.jpg" -s:v 640x480 -c:v libx264 -crf 17 -pix_fmt yuv420p timelapse_20210503.mp4

quote from article: on what the different tags actually do. They only one that matters is

-s:v 1440x1080 my version is -s:v 1440x1080

framerate: the number of images to render per second in the video
pattern_type: we set this to glob to tell ffmpeg to use all the images that match the pattern in the following parameter.

i: a pattern that matches all the input photos in your timelapse. Note that this, as with most other things on a UNIX command line, is case sensitive.

s:v: The size of the output video. Ensure that the aspect ratio matches your photos to avoid skewing the images (we’ll talk about cropping later).

c:v: The output video codec (here, H264). More on this later.

crf: A parameter specific to the H264 codec that determines the quality/compression. More on this later.

pix_fmt: this needs to be set to yuv420p to allow many players, such as Quicktime to play the video (the FFmpeg docs say *dumb* players, I’ll be more forgiving). More on this later.

this took like 10 seconds! the other ones took over 30 mins!

Bonus! I now schedule this to run every night so i dont have to do this manually!

Note: im running raspberry pi with some non-rasbian stuff but commands should work just as well for your systems

They normal way crontab! its anoying because i have to adjust a weird config file that i forget where it is.. blah blah complain. so here where a standard linux command comes in

watch !

watch is used to run any designated command at regular intervals.

its go its own web page!

How to use the watch command, by The Linux Information Project (LINFO)

So the command

watch -n 86400 <ffmpeg here>

watch -n <your time> <your command/script>

What is this magic number?

This means the ffempg will run once every day

update: 20210609

Note: this watch command turned out not to work very well. :(. not totally sure why.

the full command

tmux new -s timelapse
cd ./path/to/timelapse/pictures
watch -n 86400 ffmpeg -framerate 30 -pattern_type glob -i "*.jpg" -s:v 640x480 -c:v libx264 -crf 17 -pix_fmt yuv420p timelapse_v1_`date "+%Y-%m-%d"`.mp4

In my case it was
watch -n 86400 ffmpeg -framerate 30 -pattern_type glob -i "./Camera1/stills/*.jpg" -s:v 640x480 -c:v libx264 -crf 17 -pix_fmt yuv420p ./timelapse_converted/timelapse_v1_`date "+%Y-%m-%d"`.mp4

(ctrl+"b") then "d"

This took a while because its running on a raspberry pi 3

How to run as a cron job


change weekly to be a time you want

modify the /etc/cron.weekly/* files

Cron job - DietPi

ls /etc/cron.weekly/
nano /etc/cron.weekly/

# Copy this into the shell


echo "Run convertion command jpg's to mp4"

#Run convertion command jpg's to mp4
echo "Converstion running"

ffmpeg -framerate 30 -pattern_type glob -i "/mnt/downloads/pi-cam/Camera1/stills/*.jpg" -s:v 640x480 -c:v libx264 -crf 17 -pix_fmt yuv420p /mnt/downloads/pi-cam//timelapse_converted/timelapse_v1_`date "+%Y-%m-%d"`.mp4 -y  || exit 0
echo "Converstion complete"

chmod +x /etc/cron.weekly/
chmod 777 /etc/cron.weekly/
ls -hal /etc/cron.weekly/

CTRL + c to close early

To test the command


Awesome it worked!

how to see logs for cron  in dietpi

journalctl | grep cron

try viewing live the logs

tail -l | journalctl | grep cron

ls /etc/cron*

Notes: tis is all done for weekly cron's to test I used ./etc/cron.daily/ instead of

I don't feel like waiting around for 1 week to test stuff :).

Update 20210714 the auto run system actually doesn't work...😢

because of the size of the operation or something not totally sure.

I've reverted to just do manually every few months


How to watch the size of the output movie change to see if its done

watch ls -la /mnt/downloads/pi-cam/timelapse_converted/

or if you like normal kbs
watch ls -lah /mnt/downloads/pi-cam/timelapse_converted/

How to count number of file in a directory

(my case to check how many photos are in my timelapse) a normal ls takes a few mins to complete!

ls /mnt/downloads/pi-cam/Camera1/stills/ | wc -l

WOW 32.4k photos!

How to switch and see running tmux sessions

>tmux new -s <NAMEHERE>

#Navigate windows
#next | prev
ctrl+b n
ctrl+b p

show bacground sessions
>tmux list-sessions

enter detached session
>tmux attach -t <NAMEHERE>

tmux attach -t timelapse
ctrl+b d


by oran collins
oranbusiness (symbol that rymes with ate)