Skip to content

Bump minimum Python to 3.11 and av to 14.0.1 #4385

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions manim/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,22 +556,22 @@ def open_partial_movie_stream(self, file_path: StrPath | None = None) -> None:
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=fps,
options=av_options,
)
stream.pix_fmt = partial_movie_file_pix_fmt
stream.width = config.pixel_width
stream.height = config.pixel_height
video_container = av.open(file_path, mode="w")
stream = video_container.add_stream(
partial_movie_file_codec,
rate=fps,
options=av_options,
)
stream.pix_fmt = partial_movie_file_pix_fmt
stream.width = config.pixel_width
stream.height = config.pixel_height

self.video_container: OutputContainer = video_container
self.video_stream: Stream = stream
self.video_container: OutputContainer = video_container
self.video_stream: Stream = stream

self.queue: Queue[tuple[int, PixelArray | None]] = Queue()
self.writer_thread = Thread(target=self.listen_and_write, args=())
self.writer_thread.start()
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.
Expand Down Expand Up @@ -647,18 +647,15 @@ def combine_files(
output_container.metadata["comment"] = (
f"Rendered with Manim Community v{__version__}"
)
output_stream = output_container.add_stream(
codec_name="gif" if create_gif else None,
template=partial_movies_stream if not create_gif else None,
)
if config.transparent and config.movie_file_extension == ".webm":
output_stream.pix_fmt = "yuva420p"
if create_gif:
"""The following solution was largely inspired from this comment
https://github.com/imageio/imageio/issues/995#issuecomment-1580533018,
and the following code
https://github.com/imageio/imageio/blob/65d79140018bb7c64c0692ea72cb4093e8d632a0/imageio/plugins/pyav.py#L927-L996.
"""
output_stream = output_container.add_stream(
codec_name="gif",
)
output_stream.pix_fmt = "rgb8"
if config.transparent:
output_stream.pix_fmt = "pal8"
Expand Down Expand Up @@ -703,6 +700,11 @@ def combine_files(
output_container.mux(packet)

else:
output_stream = output_container.add_stream_from_template(
template=partial_movies_stream,
)
if config.transparent and config.movie_file_extension == ".webm":
output_stream.pix_fmt = "yuva420p"
for packet in partial_movies_input.demux(partial_movies_stream):
# We need to skip the "flushing" packets that `demux` generates.
if packet.dts is None:
Expand Down Expand Up @@ -790,8 +792,12 @@ def combine_to_movie(self) -> None:
output_container = av.open(
str(temp_file_path), mode="w", options=av_options
)
output_video_stream = output_container.add_stream(template=video_stream)
output_audio_stream = output_container.add_stream(template=audio_stream)
output_video_stream = output_container.add_stream_from_template(
template=video_stream
)
output_audio_stream = output_container.add_stream_from_template(
template=audio_stream
)

for packet in video_input.demux(video_stream):
# We need to skip the "flushing" packets that `demux` generates.
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ classifiers = [
"Topic :: Scientific/Engineering",
"Topic :: Multimedia :: Video",
"Topic :: Multimedia :: Graphics",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Natural Language :: English",
]
requires-python = ">=3.9"
requires-python = ">=3.11"
Copy link
Member

Choose a reason for hiding this comment

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

Note: we should probably also remember to do this for mypy and ruff

dependencies = [
"audioop-lts>=0.2.1 ; python_full_version >= '3.13'",
"av>=9.0.0,<14.0.0",
"av>=14.0.1",
"beautifulsoup4>=4.12",
"click>=8.0",
"cloup>=2.0.0",
Expand Down Expand Up @@ -119,7 +117,7 @@ exclude = [

[tool.pytest.ini_options]
markers = "slow: Mark the test as slow. Can be skipped with --skip_slow"
addopts = "--no-cov-on-fail --cov=manim --cov-report xml --cov-report term -n auto --dist=loadfile --durations=0"
addopts = "--no-cov-on-fail --cov=manim --cov-report xml --cov-report term -n 10 --dist=loadfile --durations=0"
Copy link
Member

Choose a reason for hiding this comment

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

Unintended?


[tool.isort]
profile = "black"
Expand Down
Loading
Loading