Files
tool__scripts/manage-video/video-wizard/0-convert-images.sh
2026-07-09 01:05:56 +02:00

32 lines
727 B
Bash
Executable File

#!/bin/bash
TARGET_DIR="./0-input"
DURATION=1 # seconds per image
if [ ! -d "$TARGET_DIR" ]; then
echo "---->>>> Error: Directory '$TARGET_DIR' does not exist."
exit 1
fi
cd "$TARGET_DIR"
for img in *.png *.jpg *.jpeg *.webp; do
if [ -f "$img" ]; then
mp4="${img%.*}.mp4"
if ffmpeg -hide_banner -loglevel error \
-loop 1 -i "$img" \
-t $DURATION \
-movflags faststart \
-pix_fmt yuv420p \
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" \
"$mp4"; then
echo "---->>>> Converted $img to $mp4 successfully."
rm "$img"
else
echo "---->>>> Failed to convert $img."
fi
fi
done