Skip to content

Instantly share code, notes, and snippets.

@jemsgit
Last active August 20, 2022 22:21
Show Gist options
  • Save jemsgit/8622615 to your computer and use it in GitHub Desktop.
Save jemsgit/8622615 to your computer and use it in GitHub Desktop.
cut movie and make gif
#!/bin/bash
#Start time
StTime="00:02:31"
#Length of video
LenV="00:00:05"
#Quantity images per sec
R="4"
#Width of images
WIDTH="600"
#Speed of gif
DEL="10"
#Cut video
ffmpeg -ss "$StTime" -t "$LenV" -i video.MOV -vcodec copy -acodec copy out.MOV;
#Convert video to images
ffmpeg -i out.MOV -r "$R" image_%010d.png;
#Resize images
mkdir resized;
for i in image_*.png; do convert $i -resize "$WIDTH" resized/$i; done
rm -f image_*.png;
cd resized;
#Make gif
convert -delay "$DEL" -layers optimize *.png ../ani.gif
cd ..;
rm -fr resized;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment