#!/bin/bash
cd /volume1/web/public
mkdir -p _lq
for f in GROOVOLVER-IPHONE-*.MOV; do
  out="_lq/$(echo "$f" | sed "s/\.MOV$/.mp4/" | tr "A-Z" "a-z")"
  if [ -f "$out" ]; then
    echo "SKIP: $out already exists"
    continue
  fi
  echo "$(date +%H:%M:%S) CONVERTING: $f -> $out"
  ffmpeg -i "$f" -vf "scale=-2:720" -c:v libx264 -crf 23 -preset medium -c:a libmp3lame -b:a 128k -movflags +faststart -y "$out" 2>&1 | tail -1
  echo "$(date +%H:%M:%S) DONE: $out ($(du -h "$out" | cut -f1))"
done
echo "$(date +%H:%M:%S) ALL DONE"
