Skip to content

Instantly share code, notes, and snippets.

@awesomebytes
Last active January 19, 2021 23:26
Show Gist options
  • Select an option

  • Save awesomebytes/dc813aae622c2bb3fcd2c1261d390846 to your computer and use it in GitHub Desktop.

Select an option

Save awesomebytes/dc813aae622c2bb3fcd2c1261d390846 to your computer and use it in GitHub Desktop.
Create a gif from a video ubuntu commandline ffmpeg

How to create a GIF from a video

ffmpeg -i video.mp4 -r 15 -vf "scale=512:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -ss 00:00:03 -to 00:00:09 video.gif

From https://askubuntu.com/questions/648603/how-to-create-an-animated-gif-from-mp4-video-via-command-line

  • -i video.mp4 is the input video.
  • -r 15 is the FPS, 10 or 15 is usually fine, more would be too big of a file.
  • -vf "scale=512:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse optimizes the palette of colors of the gif and sets the scale (512px here, use 768 if you need it a bit bigger, but be aware of the final size of the gif if you do so, 512 is a good tradeoff).
  • -ss 00:00:03.00 is the start time of the video.
  • -to 00:00:09.00 is the end time of the video. I recommend gifs to be no longer than 10 seconds and not bigger than 10-15MB, but depends on the case.
  • video.gif (the last parameter) will be the name of the gif.

Your system needs ffmpeg installed (sudo apt-get install ffmpeg).

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