vvo / gifify

😻 Convert any video file to an optimized animated GIF.
ISC License
6.18k stars 313 forks source link

Adds the wrong frame near the end when using a custom fps #61

Closed fregante closed 3 years ago

fregante commented 7 years ago
gifify background-small.mp4 > out.gif

Original mp4 https://cl.ly/go8i

Generated gif: http://i.imgur.com/WDeM4eu.gif (lasts 5 seconds)

vvo commented 7 years ago

I am missing a bit of context or explanation here, could you detail a bit more what's wrong and maybe dig it a bit?

fregante commented 7 years ago

Compare the input and output: The MP4 loops smoothly but the generated GIF doesn't (because there's an extra frame before the last frame)

vvo commented 7 years ago

Hi @bfred-it, I am not able to easily debug this. gifify is a wrapper around command line tools. It would be great if you could dig this. If you or anyone knows why there's an extra frame, please add a comment/open a pull request

itsnwa commented 7 years ago

@bfred-it have you tried to match the output fps with the input by using --fps [number of frames per second] (without brackets)? Because it defaults to 10 I think.

fregante commented 7 years ago

That does indeed work (--fps 30). I suppose the issue is specifically when the specified framerate doesn't match the input's, even though it's a factor of that.

vvo commented 7 years ago

@bfred-it Maybe we can add that tot the readme?

fregante commented 7 years ago

If that never works with any video then it's best to remove the option and read/set it directly from the video. This last part could be the default behavior anyway.

vvo commented 7 years ago

I maybe failed at the fps computing between:

see https://github.com/vvo/gifify/blob/0b67f6df9d70d9f08ddcefc575450189dd75cb50/index.js#L172 and https://github.com/vvo/gifify/blob/0b67f6df9d70d9f08ddcefc575450189dd75cb50/index.js#L103

vvo commented 7 years ago

https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video some info on ffmpeg.