I'm using ffmpeg to extract frames from a gif file. When I use python PIL it shows that the file has 135 frames. Even the properties window in the mac shoes the same number of frames. However, ffmpeg, for some reason extracts >50000 frames. A lot of them are duplicates.

Gif file - https://78.media.tumblr.com/dd7f01acad444ca85bea050afd15afaf/tumblr_nof6lmxQLC1utshuoo1_250.gif

I'm using the following command ffmpeg -i input_gif.gif output/%d.jpg Log - https://pastebin.com/HBt58yKq

However, I found that when I run the following command it works perfectly ffmpeg -i input_gif.gif -vsync 0 output/%d.jpg Log - https://pastebin.com/Ykb7WkKA


The GIF is detected as having a frame rate of 6.67 but the individual frame delays are set as 65535 in 1/100th second units so 655.35 seconds per frame. That gives a total duration in excess of 24 hrs for 135 input frames.

The image sequence muxer is set to constant frame rate mode. So ffmpeg will probe the input's frame rate (6.67 fps) and drop or duplicate frames to match that rate if the input supplies a different number of frames (per-second). So, in recreating a 24 hr output sequence at 6.67 fps, ffmpeg will seek to produce over 500K frames. Almost all of which will be duplicates.

-vsync vfr or -vsync 0 disables the frame drop/dup behaviour.

  • 1. Why are the individual frame delays invalid? 2. Why does ffmpeg set it to this strange value which produces lots of duplicate frames? Shouldn't it do something smarter? 3. Does it mean that the gif as a problem while creating it? So i can safely use -vsync 0 for all my files (both valid and invalid right)? – simar Nov 18 '18 at 1:22
  • I amended my answer. 1&2. The delays are maxed out which indicates a broken GIF creation. 3. Yes, -vsync 0 is safe for extracting images. – Gyan Nov 18 '18 at 5:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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