Files
tool__scripts/manage-video/video-wizard/1-scale-to-width.sh
2026-07-09 01:05:56 +02:00

28 lines
711 B
Bash
Executable File

#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <common_width>"
exit 1
fi
COMMON_WIDTH=$1
INPUT_DIR="./0-input"
OUTPUT_DIR="./1-scaled"
mkdir -p "$OUTPUT_DIR"
for video_file in "$INPUT_DIR"/*.{mp4,mov,avi,m4v}; do
if [ -f "$video_file" ]; then
base_name=$(basename "$video_file")
output_file="$OUTPUT_DIR/$base_name"
ffmpeg -y -i "$video_file" -vf "scale=$COMMON_WIDTH:'ceil(ow/a/2)*2'" -c:a copy "$output_file"
rm "$video_file"
echo "---->>>> Scaled $video_file to have a width of $COMMON_WIDTH pixels and even height."
fi
done
echo "---->>>> All videos have been scaled to a common width of $COMMON_WIDTH pixels with even heights."