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
Improved quality of GIFs #1144
Improved quality of GIFs #1144
Conversation
(I'll make the new issue later) |
For the examples of this change that you have tested: in how far does the file size of the output gifs change? I can see that for the example above, the new gif is approx. 200kb larger than the old one (which seems okay to me, given that there is a respectable change in the output quality). |
@behackl In the limited cases I tried, it's almost double, though it probably depends on the GIF. I find this justifiable considering that how they currently render is just unacceptable imo. So that leaves us with this tradeoff: quality vs. file size:
So we essentially see an ~50% decrease in file size by halving the frame_rate. There are other ways to do this as well. We can use the |
Concerning tests of this : I think you could try to use it for gif. I don't know if it's possible, but it's worth a try. (i'm fine if there is no direct test for that, so don't put too much effort here) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This SGTM, and I'm fine with the +50% size, since people will generally not use a gif at 50 fps imo.
Please re-request a review from me if you decide to implement tests.
Motivation
Currently, the GIFs generated by manim are fairly ugly. They have very large circular-looking pixels and are very slow. This PR fixes that insofar as I've tested.
Overview / Explanation for Changes
The only thing I have changed is the ffmpeg command to create a GIF. There are three improvements here:
palletegen
andpalleteuse
to fix the issue with colors and "large pixels."stats_mode=diff
combined withdither=bayer:bayer_scale=5:diff_mode=rectangle
aid in making the GIF look better. Currently if a scene would benefit from different settings, that will have to be edited directly inscene_file_writer.py
In order to reduce the size of a GIF, you can either lower the frame rate, lower the resolution (and keep the same frame rate or change it), scale the GIF, etc.
Testing Status
I am not aware of any tests existing for GIFs in manim. I'd like to add some, but I am not sure if this is possible/how?
Further Comments
There are probably edge cases that still don't look too good with GIFs. For this, I will make a new issue with what I think should be a next step in the right direction.
Examples
Due to the inherent large size of GIFs and the file size limit of GitHub, I can only include small examples like these. Here you can see a GIF generated the old way, and then a new one.
Acknowledgements
Reviewer Checklist