Skip to content

Instantly share code, notes, and snippets.

@FBoucher
Created October 5, 2022 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FBoucher/d1649d82d7695952b5358ca5f58e4e44 to your computer and use it in GitHub Desktop.
Save FBoucher/d1649d82d7695952b5358ca5f58e4e44 to your computer and use it in GitHub Desktop.
Script to generate 5 sec animated GIF of all mp4 in the folder and sub-folder
clear
search_dir="/mnt/c/"
files="$(find -L "$search_dir" -type f -name '*.mp4')"
echo "Count: $(echo -n "$files" | wc -l)"
echo "$files" | while read file; do
onlyFilename=$(basename "$file")
onlyName=$(basename -s .mp4 "$file")
onlyDir="$(dirname "${file}")"
echo ..processing: $onlyFilename
dkCmd="docker run -v '${onlyDir}':/video jrottenberg/ffmpeg -r 60 -i /video/${onlyFilename} -loop 0 -vf scale=520:-1 -c:v gif -f gif -ss 00:00:01.000 -r 10 -t 5 - > previews/${onlyName}.gif"
#echo $dkCmd
echo $dkCmd >> ./listOfCmds.txt
eval $dkCmd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment