#!/bin/bash
# Create the output directory if it doesn't exist
mkdir -p out

for i in *.mov; do
  echo "Processing $i"
  
  # Set the output filename based on the input file's basename
  out=$(basename "$i" ".mov")
  output_file="out/$out.mp4"
  
  # Check if the output file already exists
  if [ -f "$output_file" ]; then
    echo "$output_file already exists. Skipping recompression."
  else
    # Compress the file if it doesn't already exist
    ffmpeg -y -i "$i" -vcodec libx264 -g 10 -crf 24 -preset superfast -vf format=yuv420p -acodec aac -strict experimental "$output_file"
    echo "$output_file created."
  fi
done