Creating a video from webcam still images with crontab and ffmpeg
Last modified on July 24, 2026 • 1 min read • 150 wordsI have a webcam that is taking images when there is movement in its view field.
#!/bin/sh## cron script to make a movie out of webcam stills## The webcam puts the images of the whole day into a folder with the date. This generates the target folder.foldername=/home/ftpuser/labcam/$(date -d "-1 days" +%Y%m%d)echo $foldername# This renames the iamges into 1.jpg, 2.jpg, etc. This is necessary for ffmpeg to recognize them. counter=1for i in $foldername/*.jpg; do new=$foldername/$counter.jpg echo $new cmd='mv $i $new' eval $cmd counter=$((counter+1))done# This does the actual conversionffmpeg -f image2 -framerate 25 -i $foldername/%d.jpg -c:v libx264 $foldername/out25.mp4# And this removes the jpg files from the target folder (in order to save space)cmd2='rm '$foldername'/*.jpg'eval $cmd2