Last Updated or created 2025-02-12
(Improvement of previous posted script)
Place below bash script in a subdir with media.
Animated GIFs are generated from the video files.
You can set the number of frames per length
#!/bin/bash #set -x mkdir -p tmp prev : > list : > index.html find ../ -type f -print | egrep -i "mp4$|wmv$|avi$|mpg$|mpeg$|flv$|mov$|divx$" > list cat list | while read movie; do rm -f tmp/* newname=$( echo $movie | tr -d ' /.[]{}()' ) if [ ! -f prev/${newname}.gif ] ; then echo "Filename : $movie" kseconds=$( mediainfo --Inform="Video;%Duration%" "$movie" ) minutes=$(( $kseconds / 60000 )) echo "Minutes : $minutes" if [ $minutes -gt 10 ] ; then rate=0.032 else rate=0.128 fi echo "ffmpeg -hide_banner -loglevel error -i $movie -r $rate -vf scale=640:-1 tmp/output_%04d.png" ffmpeg -hide_banner -loglevel error -i "$movie" -r $rate -vf scale=640:-1 tmp/output_%04d.png < /dev/null # remove first (most of the time just black or logo) rm tmp/output_0001.png echo -n "Frames : " ls tmp/out* | wc -l convert -delay 50 -loop 0 tmp/output*.png prev/${newname}.gif else echo "$movie exists ... skipping" fi echo "<h1>${movie}</h1><br>" >> index.html echo "<img src=\"prev/${newname}.gif\"><br>" >> index.html done exit 0
run and get something like below (output is still running as I made this post)