diff --git a/stopmotion.sh b/stopmotion.sh new file mode 100755 index 0000000..0f6e381 --- /dev/null +++ b/stopmotion.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +usage() { + cat < 0 (défaut : 12) + -s SIZE taille max du côté long en pixels, > 0 (défaut : 1080) + -y écraser le fichier de sortie sans demander + -h afficher cette aide +EOF +} + +INPUT="images" +OUTPUT="stop_motion.mp4" +FPS="12" +SIZE="1080" +ASSUME_YES=0 + +while getopts ":i:o:f:s:yh" opt; do + case $opt in + i) INPUT=$OPTARG ;; + o) OUTPUT=$OPTARG ;; + f) FPS=$OPTARG ;; + s) SIZE=$OPTARG ;; + y) ASSUME_YES=1 ;; + h) usage ; exit 0 ;; + \?) echo "Erreur : option inconnue -$OPTARG" >&2 ; usage >&2 ; exit 1 ;; + :) echo "Erreur : valeur manquante pour -$OPTARG" >&2 ; usage >&2 ; exit 1 ;; + esac +done + +if ! [[ $FPS =~ ^[0-9]+([.][0-9]+)?$ ]] || ! awk -v f="$FPS" 'BEGIN{exit !(f>0)}'; then + echo "Erreur : -f doit être un nombre strictement positif (reçu : $FPS)" >&2 + exit 1 +fi +if ! [[ $SIZE =~ ^[0-9]+$ ]] || ! awk -v s="$SIZE" 'BEGIN{exit !(s>0)}'; then + echo "Erreur : -s doit être un entier strictement positif (reçu : $SIZE)" >&2 + exit 1 +fi + +if ! command -v ffmpeg >/dev/null 2>&1; then + echo "Erreur : ffmpeg est introuvable. Installation : brew install ffmpeg" >&2 + exit 1 +fi +if [ ! -d "$INPUT" ]; then + echo "Erreur : le dossier d'images '$INPUT' n'existe pas." >&2 + exit 1 +fi