32 lines
829 B
Bash
Executable File
32 lines
829 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: $0 <duration>"
|
|
exit 1
|
|
fi
|
|
|
|
DURATION=$1
|
|
INPUT_DIR="./1-scaled"
|
|
OUTPUT_DIR="./2-looped"
|
|
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
for video_file in "$INPUT_DIR"/*; do
|
|
if [[ $video_file == *.mp4 ]] || [[ $video_file == *.mov ]] || [[ $video_file == *.avi ]] || [[ $video_file == *.m4v ]]; then
|
|
filename=$(basename -- "$video_file")
|
|
extension="${filename##*.}"
|
|
filename="${filename%.*}"
|
|
output_file="${OUTPUT_DIR}/${filename}.${extension}"
|
|
|
|
ffmpeg -y -stream_loop -1 -i "$video_file" -c copy -t "$DURATION" -f mp4 -y "$output_file"
|
|
|
|
rm "$video_file"
|
|
|
|
echo "---->>>> Generated looped video: $output_file"
|
|
else
|
|
echo "---->>>> Skipping non-video file: $video_file"
|
|
fi
|
|
done
|
|
|
|
echo "---->>>> All videos processed."
|