×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Massimo Zappino
Added: Feb 7, 2015 9:49 PM
Modified: Aug 27, 2017 3:32 PM
Views: 22
Tags: avi video images
  1. #!/bin/bash
  2. DAYS_RETAIN=40
  3. WORKING_DIR="/external/camera"
  4. ARCHIVE_DIR="$WORKING_DIR/archive"
  5. mkdir -p "${ARCHIVE_DIR}"
  6.  
  7. find ${ARCHIVE_DIR} -mtime +${DAYS_RETAIN} -type f -delete
  8.  
  9. cd $WORKING_DIR/watermark
  10.  
  11. FIRST_FILE=`ls | head -n1`
  12. if [ "$FIRST_FILE" == "" ]; then
  13.   echo "No file"
  14.   exit 1;
  15. fi
  16.  
  17. OUTPUT_FILENAME=`date -d "yesterday 13:00 " '+%Y-%m-%d-%s'`
  18.  
  19. cat *.jpg | avconv -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 "${ARCHIVE_DIR}/${OUTPUT_FILENAME}".avi
  20. if [ "$?" == "0" ]; then
  21.   rm -f *.jpg
  22. else
  23.   echo "ERROR making video"
  24.   exit 1
  25. fi