Add render option to use x265 with lossless settings #4170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview: What does this pull request change?
Adds an option to allow the
mp4
format to usex265
as an output codec with lossless settings, so that the output is an exact rendering of the animation. This roughly doubles the final output file size by roughly double, though possibly requires fewer resources to render.Motivation and Explanation: Why and how do your changes improve the library?
By default we use x264 when rendering to the
mp4
format withcrf
set to 23.x265 (hevc) has a
lossless mode, where the encoder is configured such that the output is an exact copy of the input.
Since
manim
scenes consist of text and shapes, the lossless mode works well for us, and ensures that the output videos will be the highest quality when desired. This means that users can safely do an editing pass without risking losing further quality.Anecdotally, I've noticed slightly better performance than x264 with about 2.5x the file size.
Before:
Before (1,436,872 bytes):
$ time venv/bin/manim -pqm quad.py Fermat ... venv/bin/manim -pqm quad.py Fermat 59.41s user 144.46s system 253% cpu 1:20.44 total
After (3,494,923 bytes):
$ time venv/bin/manim -pqm quad.py Fermat --lossless ... venv/bin/manim -pqm quad.py Fermat --lossless 144.52s user 12.46s system 274% cpu 57.276 total
So, I added this as an option (for
mp4
containers).Links to added or changed documentation pages
N/A
Further Information and Comments
N/A
Reviewer Checklist