Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@shazow

This comment has been minimized.

Copy link
Owner Author

commented Aug 27, 2015

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
@aimhighagency

This comment has been minimized.

Copy link

commented May 20, 2016

Thanks! This works perfect.

But I updated to this:
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
You can’t perform that action at this time.