-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any way to cut flames make 60fps stickers not so slow after converted? #13
Comments
I am also having a problem with the output framerate. After conversion, the gif seems to run in slow motion. |
To check whether actual gif and tgs FPS values are different I've used the following python script from agtoever's answer on Stackoverflow: import sys
from PIL import Image
FILENAME = sys.argv[1]
def get_avg_fps(PIL_Image_object):
""" Returns the average framerate of a PIL Image object """
PIL_Image_object.seek(0)
frames = duration = 0
while True:
try:
frames += 1
duration += PIL_Image_object.info['duration']
PIL_Image_object.seek(PIL_Image_object.tell() + 1)
except EOFError:
return frames / duration * 1000
return None
def main():
img_obj = Image.open(FILENAME)
print(f"Average fps: {get_avg_fps(img_obj)}")
if __name__ == '__main__':
main() and two generated gifs:
Results:
So I conclude that tgs-to-gif does not change FPS in result gif image. Now I can only suggest changing the application for viewing GIFs. For example, the first gif on my phone opened by default gallery app displays normally, but in Google Photos app it displays "in slow motion". |
It seems like the “slow motion” problem are probably caused by the viewer does not support 60fps gif rendering? |
Seems to be. My observations point to that. If you find out something else, please write here so that I and other people can solve the problem.
Thanks for feedback :) |
hmm, since I'm viewing them in google chrome, that seems odd. Let me try again with those two sticker packs and see if I'm having the same issue. EDIT: Perhaps put in a flag so that we can set it as 60 vs 30 fps sticker to get a full speed gifs? |
I'm not a specialist in GIF format, but I found good explanation by Maadinsh why it is so: https://video.stackexchange.com/a/30160:
|
So Snappy Crab works beautifully and I can't test MoonCalfAnimation for some reason, but I did Lemurio Sticker Set: Plays slow in Windows Photo viewer, google chrome (like right on this page). https://bestoftelegram.com/animated-stickers/MrLemur The second doesn't even seem to be playing in 50fps, it's more like 30fps or 24fps version of a 60fps sticker. |
@bessx Your second gif is slow in my browser too, but... I opened it in default gallery app on my phone (I simply downloaded image from your comment) and it is playing faster than 60 fps (faster then in telegram). |
Hmmmm, I see. Then is there a way to tell the bot or set a flag to set it as you said, with 2 centiseconds per frame? That way, even if it's slightly slower than 60fps, it will be ~50fps across on all devices? |
It is not so simple because it uses third party library puppeteer-lottie that uses gifski tool... But is this the right decision anyway? It would be better and easier to create a tgs-to-mp4 bot. |
I've been thinking about it. If the gif ends up at 10ms duration for each frame (maximum speed that causes compatibility issues), could the bot send back two versions of the gif? One with the 10ms duration and one with the next highest, 20 ms duration? I think that would be a nice compromise without completely going for an mp4. That way the user themselves can decide version of the gif one to use. I know at that point an mp4 makes more sense but sometimes it's just easier to share a gif. |
Also having the same issue with this sticker https://t.me/addstickers/Peepo_Pepe |
I found pretty library rlottie. In examples I found the program that converts lottie to gif. I tried it on sticker from #13 (comment). Script #13 (comment) output:
But it does not generate transparent gifs, now I am trying to modify the lib to fix that. When I'll done I want to update the repo sources. |
Nice find! |
oh interesting, it's great that it works! what's the duration per frame actually set to in these new gifs? EDIT: It's beyond weird that the artifacting only happens when the background is transparent. I don't see a reason why that should happen in the transparent gif, but not in the one with a background. |
2
gif-h does not support transparency, it only has a PR charlietangora/gif-h#7, which is not compiling (Evil-Spirit/gif-h#1 should fix that) and has a color artefact, but it is better than nothing. |
I patched puppeteer-lottie in https://github.com/ed-asriyan/puppeteer-lottie/commit/7bbe134d31b56bc33c71e5022a5d787589c6f25d and use it as a dependency in this project. So issue should be resolved. |
Tested the latest version with |
Note that maximum fps for gifs is 50 (more details: #13 (comment)). If you sure, that fps is lower, please send me link to the sticker to test. |
@ed-asriyan , thanks for reply! Here is the download link: https://gofile.io/d/aNsus5. It would be great if you can find the solution for this sticker file 😄 |
@LouisWayne, please, pull the latest master branch and reinstall npm dependencies ( |
@ed-asriyan , THANKS A LOT! Now the generated gif file looks good! I hope the updates will be applied to the Telegram bot soon 😄 You made an amazing library and I really appreciate it. Thanks! |
@LouisWayne, the update has already been applied to the Telegram bot. You're welcome! |
As the title. Or is there any solutions to make the converted file play faster?
The text was updated successfully, but these errors were encountered: