Files
tool__scripts/manage-video/bitrate-shrinker/bitrate-shrinker.sh
2026-07-09 01:05:56 +02:00

22 lines
658 B
Bash

#!/bin/bash
# Directory containing the MP4 files
DIRECTORY="input"
OUTPUT_DIRECTORY="output"
# Navigate to the directory
cd "$DIRECTORY"
# Loop through all MP4 files in the directory
for FILE in *.mp4; do
# Skip if the file does not exist (e.g., when the glob matches no files)
[ -f "$FILE" ] || continue
# Generate output file name with prefix
OUTPUT_FILE="$OUTPU_DIRECTORY/REDUCED_BITRATE $FILE"
# Apply the ffmpeg command to reduce bitrate
ffmpeg -i "$FILE" -c:v libx264 -preset medium -b:v 2500k -pass 1 -an -f null /dev/null && \
ffmpeg -i "$FILE" -c:v libx264 -preset medium -b:v 2500k -pass 2 -c:a aac -b:a 128k "$OUTPUT_FILE"
done