Skip to content

Instantly share code, notes, and snippets.

@ojczeo
Last active May 9, 2025 20:21
Show Gist options
  • Save ojczeo/f4594273dde4df6cb9b0d8b531fd8c4f to your computer and use it in GitHub Desktop.
Save ojczeo/f4594273dde4df6cb9b0d8b531fd8c4f to your computer and use it in GitHub Desktop.
Burn timecode OS X with FFmpeg
#!/bin/bash
# Use first argument as input file, or prompt if missing
if [ -z "$1" ]; then
read -p "Enter the path to the MP4 file: " input_file
else
input_file="$1"
fi
# Check if file exists
if [ ! -f "$input_file" ]; then
echo "❌ File not found: $input_file"
exit 1
fi
# Extract path components
dir_name=$(dirname "$input_file")
file_name=$(basename "$input_file")
file_base="${file_name%.*}"
# Output path
output_file="${dir_name}/${file_base}_TC.mp4"
# Font path (monospace)
font_path="/System/Library/Fonts/Supplemental/Courier New.ttf"
# Run FFmpeg with hardware acceleration and centered timecode at bottom
ffmpeg -hwaccel videotoolbox -i "$input_file" \
-vf "drawtext=fontfile='${font_path}':text='%{pts\\:hms}':fontsize=36:fontcolor=white:x=(w-text_w)/2:y=h-line_h-40:box=1:[email protected]:boxborderw=5" \
-c:v h264_videotoolbox -b:v 10M -c:a copy "$output_file"
# Completion message
echo ""
echo "✅ Done! File with burned-in timecode saved as:"
echo "$output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment