Skip to content

Instantly share code, notes, and snippets.

@itsrishabh
itsrishabh / bash_batch
Last active August 29, 2015 14:08
Bash batch conversion from mp4 to png array, png array to gif, PNG array to gif with transparent background, Gif scale to certain size, PNG array in one directory to Gif, PNG array in one directory and crop, and Loop video x times
// Convert mp4 to png array
for f in *; do echo "Got '${f}'"; cd ${f}; mkdir ~/Desktop/frames/${f}; ffmpeg -i ${f}.mp4 -vf scale=600:-1 -r 29.97 ~/Desktop/frames/${f}/ffout_"${f%.mp4}%03d.png"; cd ..; done
// Convert png array to gif
for D in *; do echo "Got '${D}'"; cd ${D}; convert -dispose none -delay 3 -loop 0 ffout* ~/Desktop/gif/${D}.gif; cd ..; done
// Scale mp4 to png array at certain size
for f in *.mp4; do ffmpeg -i ${f} -vf scale=160:-1 -r 29.97 ~/Desktop/"${f}"; done
// PNG array to gif with transparent background