Last update 20210609
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
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
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
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 is used to run any designated command at regular intervals.
its go its own web page!
So the command
watch -n 86400 <ffmpeg here>
What is this magic number?
This means the ffempg will run once every day
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 ls 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
ls /etc/cron.weekly/ nano /etc/cron.weekly/convert_timelaspe.sh # Copy this into the shell #------------------------------------ #!/bin/bash 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/convert_timelaspe.sh chmod 777 /etc/cron.weekly/convert_timelaspe.sh ls -hal /etc/cron.weekly/convert_timelaspe.sh ./etc/cron.weekly/convert_timelaspe.sh 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
Notes: tis is all done for weekily cron's to test i used
./etc/cron.daily/convert_timelaspe.sh instaead of
I dont feel like waiting around for 1 week to test stuff :).
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
QUICK SETUP >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 github.com/wisehackermonkey oranbusiness (symbol that rymes with ate) gmail.com 20210609