# basic conversion
ffmpeg -i MVI_6654.MOV firsttry.gif
# -t flag to specify duration of the file
ffmpeg -t 2 -i MVI_6654.MOV secondtry.gif
# -r for framerate, the order of the flags affects the output file, keep in mind
ffmpeg -t 2 -i MVI_6654.MOV -r "15" thirdtry.gif
#The -ss flag defines the starting point. Your seconds can be decimals. If you have a longer video and want to define the starting position in hours, minutes, seconds, you can use “hh:mm:ss” format, like “00:00:03” instead of “3”
ffmpeg -t 3 -ss 0.5 -i MVI_6663.MOV -r "15" fourthtry.gif
# To reduce file size; We have to generate a custom color palette so we don’t waste space storing colors we don’t use (the gif file format is limited to 256 colors):
# -vf is a way to invoke filters on our video. so we can describe fps and scale here
ffmpeg -ss 2.6 -t 1.3 -i MVI_7035.MOV -vf fps=15,scale=320:-1:flags=lanczos,palettegen palette.png
ffmpeg -ss 2.6 -t 1.3 -i MVI_7035.MOV -i palette.png -filter_complex "fps=15,scale=400:-1:flags=lanczos[x];[x][1:v]paletteuse" sixthtry.gif
#################################
# Another method from giphy.com #
#################################
# 1- Generate color palette
ffmpeg -ss 61.0 -t 2.5 -i StickAround.mp4 -filter_complex "[0:v] palettegen" palette.png
# 2- Convert to gif using the color palette
ffmpeg -ss 61.0 -t 2.5 -i StickAround.mp4 -i palette.png -filter_complex "[0:v][1:v] paletteuse" prettyStickAround.gif
## Combination of [1] and [2]
$ ffmpeg -ss 61.0 -t 2.5 -i StickAround.mp4 -filter_complex "[0:v] fps=12,scale=480:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" SmallerStickAround.gif