Skip to content

Instantly share code, notes, and snippets.

@mstevenson
Last active Jul 18, 2022
Embed
What would you like to do?
Shell script to batch convert old QuickTime moves to MP4
  1. Install Homebrew through the macOS Terminal: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install ffmpeg: brew install ffmpeg
  3. Copy the mov_to_mp4.sh script into a folder containing one or more QuickTime files.
  4. Change to the directory containing the script: cd /path/to/mov_to_mp4.sh
  5. Run the script to batch convert all .mov files to .mp4. Results will be stored in a subfolder named "output". sh mov_to_mp4.sh

This will create visually lossless mp4 videos that will play in a modern version of QuickTime. If a truly pixel-perfect lossless file is desired, change -crf 15 to -crf 0. The resulting file will not play in QuickTime, but this is useful for creating intermediate archival copies that can be converted to a new format in the future without degradation.

#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
OUTPUT="$SCRIPT_DIR/output"
if [ ! -d "$OUTPUT" ]; then
mkdir -p "$OUTPUT";
fi
for i in *.mov;
do ffmpeg -n -i "$i" -c:v libx264 -preset veryslow -pix_fmt yuv420p -crf 15 -c:a aac "$OUTPUT/${i%.*}.mp4";
done
#!/usr/bin/env bash
# Create a QuickTime movie with Cinepak encoding, playable on 68k Macs.
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
OUTPUT="$SCRIPT_DIR/output"
SCALE=320
FPS=10
if [ ! -d "$OUTPUT" ]; then
mkdir -p "$OUTPUT";
fi
for i in *.mp4;
do ffmpeg -n -i "$i" -c:v cinepak -q:v 10 -r $FPS -vf "scale=$SCALE:$SCALE:force_original_aspect_ratio=decrease" -c:a pcm_s8 -f mov "$OUTPUT/${i%.*}.mov";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment