Skip to content
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

[Misc] Improve gif output compression rate #6289

Merged
merged 5 commits into from
Nov 4, 2022
Merged

[Misc] Improve gif output compression rate #6289

merged 5 commits into from
Nov 4, 2022

Conversation

neozhaoliang
Copy link
Contributor

Issue: #6183

@netlify
Copy link

netlify bot commented Oct 11, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 3967c78
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/635ba751fb339a000a77a28b
😎 Deploy Preview https://deploy-preview-6289--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@neozhaoliang neozhaoliang changed the title [Lang] Fix gif compression size [Enhancement] Fix gif compression size Oct 11, 2022
@neozhaoliang neozhaoliang marked this pull request as draft October 11, 2022 08:22
@yuanming-hu yuanming-hu self-requested a review October 14, 2022 07:14
@yuanming-hu
Copy link
Member

Thanks, will take a look next week!

@neozhaoliang neozhaoliang changed the title [Enhancement] Fix gif compression size [Tools] Fix gif compression size Oct 14, 2022
@neozhaoliang neozhaoliang changed the title [Tools] Fix gif compression size [Tool] Fix gif compression size Oct 14, 2022
@neozhaoliang neozhaoliang changed the title [Tool] Fix gif compression size [enhancement] Fix gif compression size Oct 14, 2022
@neozhaoliang neozhaoliang changed the title [enhancement] Fix gif compression size [Lang] Fix gif compression size Oct 14, 2022
@yuanming-hu
Copy link
Member

Many thanks for the PR - could you help benchmark the output size of the old ffmpeg approach against the new moviepy approach?

@yuanming-hu yuanming-hu marked this pull request as ready for review October 28, 2022 07:00
@neozhaoliang
Copy link
Contributor Author

Many thanks for the PR - could you help benchmark the output size of the old ffmpeg approach against the new moviepy approach?

The improvement in compression size is quite good. I used a 1.8MB size mp4 video to test the two methods:

  1. The original way results in a 13.3MB gif.
  2. moviepy outputs a 4.3MB gif.

@houkensjtu also has some insights on this comparison.

@houkensjtu
Copy link
Contributor

FYI, I tested this PR using the taichi_dem repo. Previously, with the default frame rate and resolution, the gif generated by the first 100 frames output is around 45 MB. With this PR, the size is reduced to 32 MB.

I guess the reason why the compression rate is not as good as @neozhaoliang 's result is that the frames from DEM are all black & white.

The commands I used to generate the gif are as follows:

ti video
ti gif -i video.mp4

Overall, I think it's a good improvement over the ffmpeg method. We may include a comment in the doc to warn the users about the size of the generated gif, and point them to third-party compression tools (such as ezgif) if they wish so.

Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you both! :-)

@yuanming-hu yuanming-hu changed the title [Lang] Fix gif compression size [Lang] Improve gif output compression rate Nov 4, 2022
@yuanming-hu yuanming-hu changed the title [Lang] Improve gif output compression rate [Misc] Improve gif output compression rate Nov 4, 2022
@yuanming-hu yuanming-hu merged commit 2b5eff8 into master Nov 4, 2022
@neozhaoliang neozhaoliang deleted the fix-gif branch November 4, 2022 02:53
ailzhang added a commit that referenced this pull request Nov 4, 2022
ailzhang added a commit that referenced this pull request Nov 4, 2022
@neozhaoliang neozhaoliang restored the fix-gif branch November 4, 2022 14:14
quadpixels pushed a commit to quadpixels/taichi that referenced this pull request May 13, 2023
quadpixels pushed a commit to quadpixels/taichi that referenced this pull request May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants