I'm trying to generate a GIF thumbnail out of a video, similar to what youtube thumbnail works when we hover the mouse on a thumbnail as a video preview.

Is there any ways to do it with FFmpeg? Say I want to generate a 2-3 second GIF out of a video. How can I do that? Based on what I see from youtube, apparently it takes one frame out of multiple consecutive frames, not all of them.

I'm not really concerned if that GIF is a good representative of the video as that is more semantic problem to investigate.

  • .You want to pick every Nth frame and compose a GIF?
    – Gyan
    May 28, 2019 at 20:04
  • @Gyan That. Plus another approach can be pick multiple consecutive I-frames (or every Nth I-frame) and compose a GIF.
    – angel_30
    May 28, 2019 at 21:12

1 Answer 1


There is thumbnail filter just for that, and palettegen/paletteuse to create high quality gif.

Example command: "scale=vga,thumbnail=100,split[a][b],[b]palettegen=reserve_transparent=0:stats_mode=single[b];[a][b]paletteuse=new=1,settb=1/25,setpts=N"

Thumbnail filter selects one frame from set of 100 frames. To get gif of 3 secs, you will need to adjust this number to smaller or bigger value depending on source file number of frames.

  • I get your point. But the GIF it generates is awkward! Here is the gif: dropbox.com/s/0igto0uothaz13c/output3.gif from this video: dropbox.com/s/j6yqn83399kzxy3/debate.mp4
    – angel_30
    May 28, 2019 at 21:11
  • The above command was just example. I can not guess what you really want/need. How much time each frame should last, etc, etc..
    – user12174
    May 28, 2019 at 21:27
  • I see. Thanks. Maybe say consecutive I-frames worth of 3 seconds?
    – angel_30
    May 28, 2019 at 21:35
  • I doubt selecting I-frames is worthy goal. For selecting 3 seconds of frames, I will need duration in milliseconds of each displayed gif frame and number of frames in source video.
    – user12174
    May 29, 2019 at 8:01
  • 1
    For selecting I-frames only you use select filter before thumbnail filter. And use number of I-frames instead of all video frames when calculating number for n thumbnail option. This needs some shell scripting too. Off course you can use duration of video and video frame-rate to derive number of video frames but this may not be always correct.
    – user12174
    May 30, 2019 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.