Skip to content

Instantly share code, notes, and snippets.

@aaronk6
Last active December 31, 2015 05:39
Show Gist options
  • Save aaronk6/7942152 to your computer and use it in GitHub Desktop.
Save aaronk6/7942152 to your computer and use it in GitHub Desktop.
Converts all GIF files in the current folder and its subfolders to MP4 files so they can be used in applications that don't support animated GIFs. Tested on OS X 10.9, requires ffmpeg >= 1.2.
#!/bin/bash
# Converts all GIF files in the current folder and its subfolders to MP4 files
# so they can be used in applications that don't support animated GIFs
# requires ffmpeg >= 1.2
# target format: H.264 baseline, level 3.0 @ 30 fps
width=320
height=240
find . -type f -iname "*.gif" -print0 |
xargs -0 -I {} ffmpeg -i '{}' -n -c:v libx264 -r 30 \
-preset slow -profile:v baseline -level 3.0 -pix_fmt yuv420p \
-filter:v "scale=iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih), pad=$width:$height:($width-iw*min($width/iw\,$height/ih))/2:($height-ih*min($width/iw\,$height/ih))/2" \
'{}.mp4'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment