Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Batch convert a directory of gifs into mp4
# Convert *.gif into *.mp4, skip if already exists.
for path in *.gif; do
[[ -f "$out" ]] && continue
ffmpeg -f gif -i "${path}" "${out}"

This comment has been minimized.

Copy link
Owner Author

@shazow shazow 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  # Make it executable
$ ./

This comment has been minimized.

Copy link

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