Repository: ManimCommunity/manim
File: manim/scene/scene_file_writer.py (Python)

Code before:
        }

        if config.format == "webm":
            partial_movie_file_codec = "libvpx-vp9"
            av_options["-auto-alt-ref"] = "1"
            if config.transparent:
                partial_movie_file_pix_fmt = "yuva420p"

        elif config.transparent:
            partial_movie_file_codec = "qtrle"
            partial_movie_file_pix_fmt = "argb"

        with av.open(file_path, mode="w") as video_container:
            stream = video_container.add_stream(
                partial_movie_file_codec,
                rate=config.frame_rate,
                options=av_options,
            )
            stream.pix_fmt = partial_movie_file_pix_fmt
            stream.width = config.pixel_width
            stream.height = config.pixel_height

            self.video_container = video_container
            self.video_stream = stream

            self.queue: Queue[tuple[int, PixelArray]] = Queue()
            self.writer_thread = Thread(target=self.listen_and_write, args=())
            self.writer_thread.start()

    def close_partial_movie_stream(self) -> None:
        """Close the currently opened video container.

        Used internally by Manim to first flush the remaining packages
        in the video stream holding a partial file, and then close
        the corresponding container.
        """
        self.queue.put((-1, None))
        self.writer_thread.join()

        for packet in self.video_stream.encode():
            self.video_container.mux(packet)

        self.video_container.close()

        logger.info(
            f"Animation {self.renderer.num_plays} : Partial movie file written in %(path)s",
            {"path": f"'{self.partial_movie_file_path}'"},
        )

    def is_already_cached(self, hash_invocation: str):
        """Will check if a file named with `hash_invocation` exists.

Review comment (suggestion):
Ah I made a small mistake here, my bad.
```suggestion
            self.queue: Queue[tuple[int, PixelArray | None]] = Queue()
```

Code after:
        }

        if config.format == "webm":
            partial_movie_file_codec = "libvpx-vp9"
            av_options["-auto-alt-ref"] = "1"
            if config.transparent:
                partial_movie_file_pix_fmt = "yuva420p"

        elif config.transparent:
            partial_movie_file_codec = "qtrle"
            partial_movie_file_pix_fmt = "argb"

        with av.open(file_path, mode="w") as video_container:
            stream = video_container.add_stream(
                partial_movie_file_codec,
                rate=config.frame_rate,
                options=av_options,
            )
            stream.pix_fmt = partial_movie_file_pix_fmt
            stream.width = config.pixel_width
            stream.height = config.pixel_height

            self.video_container = video_container
            self.video_stream = stream

            self.queue: Queue[tuple[int, PixelArray | None]] = Queue()
            self.writer_thread = Thread(target=self.listen_and_write, args=())
            self.writer_thread.start()

    def close_partial_movie_stream(self) -> None:
        """Close the currently opened video container.

        Used internally by Manim to first flush the remaining packages
        in the video stream holding a partial file, and then close
        the corresponding container.
        """
        self.queue.put((-1, None))
        self.writer_thread.join()

        for packet in self.video_stream.encode():
            self.video_container.mux(packet)

        self.video_container.close()

        logger.info(
            f"Animation {self.renderer.num_plays} : Partial movie file written in %(path)s",
            {"path": f"'{self.partial_movie_file_path}'"},
        )

    def is_already_cached(self, hash_invocation: str):
        """Will check if a file named with `hash_invocation` exists.