Skip to content

Instantly share code, notes, and snippets.

@arjunmenon
Forked from shazow/convert-gifs.sh
Created August 26, 2017 13:41
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 arjunmenon/79814056a221ae6cca23ca3277c32f64 to your computer and use it in GitHub Desktop.
Save arjunmenon/79814056a221ae6cca23ca3277c32f64 to your computer and use it in GitHub Desktop.
Batch convert a directory of gifs into mp4
#!/usr/bin/bash
# Convert *.gif into *.mp4, skip if already exists.
outdir="."
for path in *.gif; do
out="${outdir}/${path/.gif/}.mp4"
[[ -f "$out" ]] && continue
ffmpeg -f gif -i "${path}" "${out}"
done
@arjunmenon
Copy link
Author

Feel free to copy-and-paste the body into your shell while in the dir with *.gif files, or download the file and:

$ chmod +x convert-gifs.sh  # Make it executable
$ ./convert-gifs.sh

@arjunmenon
Copy link
Author

for path in *.gif; do out="${outdir}/${path/.gif/}.mp4"; [[ -f "$out" ]] && continue; ffmpeg -f gif -i "${path}" -pix_fmt yuv420p "${out}"; done
That way the output works in Quicktime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment