View Single Post
turtle
Lord of the Rant.
Formerly turtle2472
 
Join Date: Mar 2005
Location: Upstate South Carolina
 
2022-07-19, 13:28

I think I finally have the monthly thing figured out. I wrote this and am pretty certain it will work out as needed for me. The original plan was to write one script per camera like I've done for the daily time lapse videos. This time I wanted to use a list and loops instead. This means I edit the lists when/if I add more cameras to build time lapse videos from.

Code:
# Monthly TimeLapse job 0 2 1 * * /home/turtle2472/monthlyTimeLapse.sh > /dev/null 2>&1 [turtle2472@timelapse ~]$ cat /home/turtle2472/monthlyTimeLapse.sh #!/bin/bash # Variables: SECONDS=0 logging="logger -p info -t monthlyProcessing -d -n 10.10.10.10 -P 514 " previousMonth=`nowmonth=$(date +%Y-%m) && date -d "$nowmonth-15 last month" '+%Y%m'` cameraList="backYardImages c754Images frontDoorImages G3instantImages grannaLairImages rollupDoorImages" tlFolder="backYard c754 frontDoor G3instant grannaLair rollupDoor" $logging "Beginning Monthly Process" # Remove corrupt and incomplete image files based on size from primary image folders for r in $(echo $cameraList); do find /home/turtle2472/timeLapse/$r/ -type f -size -20k -name \*.jpg -exec rm -rf {} \;; done # Create Archive monthly subfolders for i in $(echo $cameraList); do mkdir /home/turtle2472/timeLapse/archiveCameraImages/$i/$previousMonth; done # Move images files to archive monthly subfolder for f in $(echo $cameraList); do find /home/turtle2472/timeLapse/$f/ -type f -name $previousMonth\* -exec mv '{}' /home/turtle2472/timeLapse/archiveCameraImages/$f/$previousMonth/ \;; done # Create monthly timelapse for t in $(echo $tlFolder); do cd /home/turtle2472/timeLapse/archiveCameraImages/"$t"Images/$previousMonth/ && nice ffmpeg -hide_banner -loglevel warning -r 24 -pattern_type glob -i '*.jpg' -vcodec libx264 -pix_fmt yuv420p /mnt/nfs/TimeLapse/$t/Specials/S0E$previousMonth_timelapse.mp4 duration=$SECONDS maths="$(($duration/3600)) hours, $(($duration%3600 / 60)) minutes and $(($duration % 60)) seconds elapsed." $logging $maths $logging "Completed Monthly Process"
I was going to breakdown what each step does but I've got to get to a meeting right now. If anyone wants me to explain I'd be happy to latter.

Louis L'Amour, “To make democracy work, we must be a notion of participants, not simply observers. One who does not vote has no right to complain.”
MineCraft? mc.applenova.com | Visit us! | Maybe someday I'll proof read, until then deal with it.
  quote