Skip to content

Instantly share code, notes, and snippets.

@rrbutani
Last active June 20, 2017 19:59
Show Gist options
  • Save rrbutani/40b2cd1ef505c1f11be2760f7c0e2dab to your computer and use it in GitHub Desktop.
Save rrbutani/40b2cd1ef505c1f11be2760f7c0e2dab to your computer and use it in GitHub Desktop.
middleman.sh
bash middleman.sh "/home/odroid/raw-images" "/home/odroid/Image Corrector Images/new" "/tmp/enabled"
#!/bin/bash
# Pass raw input image directory ($1: i.e. ~/raw-images/)
# And processing image directory ($2: i.e. ~/Image\ Corrector\ Images\new/)
# And file to control if the middleman does anything ($3)
# If file exists, will copy over
# If file does not exist, will not copy over
PDIR=$(date +%H:%M.%h-%d-%Y)
PDIR="${1}/${PDIR}-processed"
# Make processed dir.
mkdir -p "${PDIR}"
# Run until stopped:
while true; do
# Every second..
if [[ "$(date +%N)" == 00* ]]; then
for newImage in "${1}"/*.jpg; do
# If we're enabled...
if [ -a "${3}" ]; then
#...then copy to the processing image directory
#...and retain timestamp.
cp -p "${newImage}" "${2}"
echo "Copied ${newImage} to ${2}"
fi
# Regardless, move the file to mark as processed:
cp -p "${newImage}" "${PDIR}"
rm "${newImage}"
echo "Moved ${newImage} to ${PDIR}"
done
fi
sleep 0.1
done
count=0; for i in *.jpg; do a=(${i//2017/ }); a=$(basename ${a[1]#0} .jpg); if [[ a -lt 100801 ]]; then echo ${a}; ((count++)); fi; done; echo ${count}
ffmpeg -r 30 -i %*.jpg -s hd1080 -vcodec libx264 -vframes ${count} time-lapse.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment