Skip to content

Instantly share code, notes, and snippets.

@kevin-miles
Created September 30, 2025 08:41
Show Gist options
  • Save kevin-miles/14bc8d5d28d083fdf174a56a5cf69f6f to your computer and use it in GitHub Desktop.
Save kevin-miles/14bc8d5d28d083fdf174a56a5cf69f6f to your computer and use it in GitHub Desktop.
FFMPEG Batch Compress Parallel
#!/bin/bash
# A script to batch-compress MP4 files in parallel using GNU Parallel
# Create a directory for the output files if it doesn't exist
mkdir -p compressed
echo "Starting parallel processing..."
# Find all .mp4 files and pipe them to GNU Parallel to run ffmpeg jobs simultaneously
# --bar shows a progress bar
# {} is the placeholder for the input file (e.g., video.mp4)
# {/.} is the placeholder for the basename of the file without its extension (e.g., video)
find . -maxdepth 1 -name "*.mp4" | parallel --bar ffmpeg -n -i {} \
-c:v libx264 \
-crf 28 \
-preset medium \
-c:a aac \
-b:a 128k \
"compressed/{/.}_compressed.mp4"
echo "Batch processing complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment