Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Last active December 23, 2021 17:42
Show Gist options
  • Save ddrscott/6831b4027d6503cf9cbdf1790fc79d16 to your computer and use it in GitHub Desktop.
Save ddrscott/6831b4027d6503cf9cbdf1790fc79d16 to your computer and use it in GitHub Desktop.
Concatenating two parts of a video into a gif
FRAMERATE:=12
shoyo-spike.gif: clip-a.gif clip-b.gif
ffmpeg -i clip-a.gif -i clip-b.gif \
-filter_complex 'concat=n=2:v=1:a=0,scale=480:-1' \
-r ${FRAMERATE} -y $@
clip-a.gif:
ffmpeg -ss 06:08 -to 06:21.5 -i source-clip.mp4 -r ${FRAMERATE} -y $@
clip-b.gif:
ffmpeg -ss 06:36.0 -to 06:39 -i source-clip.mp4 -r ${FRAMERATE} -y $@
## Example doing it all in a single command.
single.gif:
ffmpeg \
-ss 06:08 -to 06:21.5 -i source-clip.mp4 \
-ss 06:36 -to 06:39 -i source-clip.mp4 \
-filter_complex 'concat=n=2:v=1:a=0,scale=480:-1' \
-r ${FRAMERATE} -y $@
@ddrscott
Copy link
Author

make final.gif

shoyo-spike

@ddrscott
Copy link
Author

ddrscott commented Dec 23, 2021

I tried making the gif as a single command and it worked! ffmpeg is also able to make a smaller final file so I bumped the default framerate back up to 12.

single

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment