Skip to content

FIX : 472 / Small refactor of partial-movie-files handling #489

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

Merged
merged 14 commits into from
Oct 9, 2020

Conversation

huguesdevimeux
Copy link
Member

@huguesdevimeux huguesdevimeux commented Sep 29, 2020

List of Changes

  • Refactored partial movie files handling. See explanation below.
  • Added some extra logs that output partial movie files stuff, to make debugging easier.

Motivation

Explanation for Changes

#472 undercovers two issues :

  • The first one is related to SceneFileWriter. To write a new partial movie file, it used to take in order the next hash in animation_hashes list of a scene. SceneFileWriter keeps its own index of partial movie files, independently of Scene. I think some code is better than my explanations : See get_next_partial_movie_file method, and scene_file_writer own index is self.index_partial_movie_file .

https://github.com/ManimCommunity/manim/blob/master/manim/scene/scene_file_writer.py#L189-L210

This is bad, very bad, in some particular cases, like when the first animation is skipped as already cached. Then, the list of partial movie file is updated, but as sceneFIleWriter has its own index, sceneFIleWriter will think it's the first animation instead of the second one. I know, it's tricky. I fixed this by getting rid of this index. The index is now scene.num_plays.

  • Manim didn't make any difference between animation skipped because cached and animation skipped because of -n. The first ones have to be rendered in the final movie, the second one not. This is now fixed. If an animation has to be skipped because of a flag, the animation_hashes_list will be appened by None, and by the hash otherwise. Like this, the index (scene.num_plays) is not bigger than animation_hashes list.

Testing Status

tests for -n flag exited with no issue.
It's impossible to proper test this, as we have no possibility to test caching yet.

Acknowledgement

@huguesdevimeux huguesdevimeux added the test requested Implementation of tests are requested label Sep 29, 2020
@huguesdevimeux huguesdevimeux removed the test requested Implementation of tests are requested label Sep 29, 2020
@huguesdevimeux huguesdevimeux marked this pull request as ready for review September 29, 2020 07:32
@huguesdevimeux huguesdevimeux requested review from Aathish04, behackl, cobordism and leotrs and removed request for Aathish04 September 29, 2020 11:43
@cobordism
Copy link
Member

Manim didn't make any difference between animation skipped because cached and animation skipped because of -n. The first ones have to be rendered in the final movie, the second one not.

True that the animation doesn't have to be rendered, but the end result of it (the final svg) does. right?

@huguesdevimeux
Copy link
Member Author

True that the animation doesn't have to be rendered, but the end result of it (the final svg) does. right?

It depends on which animation you are talking about. If the animation is cached, then it should appear on the final video.if the animation is purposely skipped with for example -n, then it should not be on the final video.

@huguesdevimeux
Copy link
Member Author

I think I adressed all the changes requests. Feel free to review !

@cobordism
Copy link
Member

True that the animation doesn't have to be rendered, but the end result of it (the final svg) does. right?

It depends on which animation you are talking about. If the animation is cached, then it should appear on the final video.if the animation is purposely skipped with for example -n, then it should not be on the final video.

Not entirely.
If my first five animations are write animations for text, and I render the scene with -n 5, then the text should be visible in the first frame of the output video. i.e. we skip the write animation but we still see the resulting image.

@huguesdevimeux
Copy link
Member Author

huguesdevimeux commented Oct 1, 2020

I don't think your idea of how partial movie files work is correct.
Partial movie files are basically the final movie cut in several parts, which correspond to each animation (i.e, each play.wait call). So, partial movie file n + 1 contains all the objects that were on the screen at animation n.

Example :

class PartialMovieFiles(Scene):
    def construct(self):
        self.play(ShowCreation(Tex("A", color=RED)))
        self.play(ShowCreation(Tex("B", color=GREEN).shift(DOWN)))
        self.play(ShowCreation(Tex("C", color=BLUE).shift(2 * DOWN)))

Partial movie file for second self.play

As you can see, there is the red A on the screen, at the beginning.

@cobordism
Copy link
Member

As you can see, there is the red A on the screen, at the beginning.

then we've been in agreement all along but only just found out :D

@eulertour eulertour mentioned this pull request Oct 1, 2020
13 tasks
@behackl behackl added this to the Release v0.1 milestone Oct 1, 2020
Copy link
Member

@cobordism cobordism left a comment

Choose a reason for hiding this comment

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

I am not is a position to review the code itself, however I have tested the code and all my compilation errors have disappeared... i.e. the code seems to work :)

The only errors I found was when supplying a -n flag with a number higher than the number of animations in the video. In other words, if my video has 6 animation and I run manim -pl -n 7 then, instead of exiting gracefully, I get the error:

/home/cobordism/Documents/renderings/videos/example2/480p15/partial_movie_files/TestZoom1/partial_movie_file_list.txt: Invalid data found when processing input

and then, instead of stopping, the -p flag kicks in and proceeds to play the previously rendered video that is already in the media dir.

...but since that is a strange edge case for the -n flag, I think that is something we can address another PR

@PgBiel PgBiel added the pr:bugfix Bug fix for use in PRs solving a specific issue:bug label Oct 3, 2020
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

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

There seems to be some problem with the pipeline on macOS, but these errors are unrelated to this PR.

Good to go!

@behackl behackl merged commit dde2228 into ManimCommunity:master Oct 9, 2020
@huguesdevimeux huguesdevimeux deleted the fix-472 branch October 9, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:bugfix Bug fix for use in PRs solving a specific issue:bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[scene caching] partial movie file not found
5 participants