Skip to content

Commit 1f249e4

Browse files
behacklpre-commit-ci[bot]jeertmans
authored
Let SceneFileWriter access ffmpeg via av instead of via external process (#3501)
* added av as a dependency * make partial movie files use av instead of piping to external ffmpeg * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * opengl rendering: use av for movie files * no need to check for ffmpeg executable * refactor: *_movie_pipe -> *_partial_movie_stream * improve (oneline) documentation * pass more options to partial movie file rendering * move ffmpeg verbosity settings to config; renamed option dict * replaced call to ffmpeg in combine_files by using av Co-authored-by: Jérome Eertmans <jeertmans@icloud.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * there was one examples saved as a gif? * chore(deps): re-order av * chore(lib): simplify `write_frame` method Reduces the overall code complexity * chore(lib): add audio * fix(lib): same issue for conversion * fix(lib): webm export * fix(lib): transparent export Though the output video is weird * try(lib): fix gif + TODOs * chore(deps): lower dep crit * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * feat(lib): add support for GIF * fix(ci): rewrite tests * fix * chore(ci): prevent calling concat on empty list * add missing dot * fix(ci): update frame comparison ? * fix(log): add handler to libav logger * chore: add TODO * fix(lib): concat issue * Revert "fix(ci): update frame comparison ?" This reverts commit 904cfb4. * fix(ci): make it pass tests * chore(lib/docs/ci): remove FFMPEG entirely This removes any reference to FFMPEG, except in translation files * added av as a dependency * make partial movie files use av instead of piping to external ffmpeg * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * opengl rendering: use av for movie files * no need to check for ffmpeg executable * refactor: *_movie_pipe -> *_partial_movie_stream * improve (oneline) documentation * pass more options to partial movie file rendering * move ffmpeg verbosity settings to config; renamed option dict * replaced call to ffmpeg in combine_files by using av Co-authored-by: Jérome Eertmans <jeertmans@icloud.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * there was one examples saved as a gif? * chore(deps): re-order av * chore(lib): simplify `write_frame` method Reduces the overall code complexity * chore(lib): add audio * fix(lib): same issue for conversion * fix(lib): webm export * fix(lib): transparent export Though the output video is weird * try(lib): fix gif + TODOs * chore(deps): lower dep crit * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * feat(lib): add support for GIF * fix(ci): rewrite tests * fix * chore(ci): prevent calling concat on empty list * add missing dot * fix(ci): update frame comparison ? * fix(log): add handler to libav logger * chore: add TODO * fix(lib): concat issue * Revert "fix(ci): update frame comparison ?" This reverts commit 904cfb4. * fix(ci): make it pass tests * chore(lib/docs/ci): remove FFMPEG entirely This removes any reference to FFMPEG, except in translation files * chore(deps): update lockfile * chore(lib): rewrite ffprobe * fix typo * slightly more aggressive removal of ffmpeg in docs; minor language changes * fix gif output stream dimensions * minor style change * fix encoding of (transparent) mov files * fixed metadata / comment * set frame rate for --format=gif in output_stream * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * more video tests for different render settings, also test pix_fmt * improve default bitrate setting via crf * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * parametrized format/transparency rendering test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * context managers for (some) av.open * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update manim/utils/commands.py Co-authored-by: Jérome Eertmans <jeertmans@icloud.com> * fixed segfault * update test data involving implicit functions (output improved!) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * explicity set pix_fmt for transparent webms * special-special case extracting frame from vp9-encoded file with transparency * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix transparent gifs, more special casing in parametrized video format test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * run tests on macos-latest again * removed old control data * Revert "run tests on macos-latest again" This reverts commit f50efa4. * added sound to codec test; fixed issue with sound track in gif (disabled) and webm (now via opus) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * manual wav -> ogg transcoding * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed f-string * refactored codec test, split out gif * check for non-zero audio samples * more cleanup * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove ffmpeg from readthedocs apt_packages * round up run_time if positive and shorter than current frame rate * added more run_time tests * black * improve implementation of test * removed some unused imports * improve wording of logged warning Co-authored-by: Jérome Eertmans <jeertmans@icloud.com> * move run_time checks from Animation.begin to Scene.get_run_time * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove unused import * flake: PT012 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jérome Eertmans <jeertmans@icloud.com>
1 parent 4bd2f86 commit 1f249e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1868
-1398
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,5 @@ PASTE HERE
7070
<!-- output of `tlmgr list --only-installed` for TeX Live or a screenshot of the Packages page for MikTeX -->
7171
</details>
7272

73-
<details><summary>FFMPEG</summary>
74-
75-
Output of `ffmpeg -version`:
76-
77-
```
78-
PASTE HERE
79-
```
80-
</details>
81-
8273
## Additional comments
8374
<!-- Add further context that you think might be relevant for this issue here. -->

.github/ISSUE_TEMPLATE/installation_issue.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,5 @@ PASTE HERE
5353
<!-- output of `tlmgr list --only-installed` for TeX Live or a screenshot of the Packages page for MikTeX -->
5454
</details>
5555

56-
<details><summary>FFMPEG</summary>
57-
58-
Output of `ffmpeg -version`:
59-
60-
```
61-
PASTE HERE
62-
```
63-
</details>
64-
6556
## Additional comments
6657
<!-- Add further context that you think might be relevant for this issue here. -->

.github/workflows/ci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ jobs:
5151
run: |
5252
echo "date=$(/bin/date -u "+%m%w%Y")" >> $GITHUB_OUTPUT
5353
54-
- name: Install and cache ffmpeg (all OS)
55-
uses: FedericoCarboni/setup-ffmpeg@v3
56-
with:
57-
token: ${{ secrets.GITHUB_TOKEN }}
58-
id: setup-ffmpeg
59-
6054
- name: Install system dependencies (Linux)
6155
if: runner.os == 'Linux'
6256
uses: awalsh128/cache-apt-pkgs-action@latest

.github/workflows/release-publish-documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Install system dependencies
2020
run: |
2121
sudo apt update && sudo apt install -y \
22-
pkg-config libcairo-dev libpango1.0-dev ffmpeg wget fonts-roboto
22+
pkg-config libcairo-dev libpango1.0-dev wget fonts-roboto
2323
wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh
2424
echo ${HOME}/.TinyTeX/bin/x86_64-linux >> $GITHUB_PATH
2525

.readthedocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ build:
77

88
apt_packages:
99
- libpango1.0-dev
10-
- ffmpeg
1110
- graphviz
1211

1312
python:

docker/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ FROM python:3.11-slim
22

33
RUN apt-get update -qq \
44
&& apt-get install --no-install-recommends -y \
5-
ffmpeg \
65
build-essential \
76
gcc \
87
cmake \

docs/source/contributing/development.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ For first-time contributors
5151
#. Install Manim:
5252

5353
- Follow the steps in our :doc:`installation instructions
54-
<../installation>` to install **Manim's dependencies**,
55-
primarily ``ffmpeg`` and ``LaTeX``.
54+
<../installation>` to install **Manim's system dependencies**.
55+
We also recommend installing a LaTeX distribution.
5656

5757
- We recommend using `Poetry <https://python-poetry.org>`__ to manage your
5858
developer installation of Manim. Poetry is a tool for dependency

docs/source/guides/deep_dive.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ The scene then asks its renderer to initialize the scene by calling
266266

267267
Inspecting both the default Cairo renderer and the OpenGL renderer shows that the ``init_scene``
268268
method effectively makes the renderer instantiate a :class:`.SceneFileWriter` object, which
269-
basically is Manim's interface to ``ffmpeg`` and actually writes the movie file. The Cairo
269+
basically is Manim's interface to ``libav`` (FFMPEG) and actually writes the movie file. The Cairo
270270
renderer (see the implementation `here <https://github.com/ManimCommunity/manim/blob/main/manim/renderer/cairo_renderer.py>`__) does not require any further initialization. The OpenGL renderer
271271
does some additional setup to enable the realtime rendering preview window, which we do not go
272272
into detail further here.
@@ -310,8 +310,8 @@ the order they are called, these customizable methods are:
310310
After these three methods are run, the animations have been fully rendered,
311311
and Manim calls :meth:`.CairoRenderer.scene_finished` to gracefully
312312
complete the rendering process. This checks whether any animations have been
313-
played -- and if so, it tells the :class:`.SceneFileWriter` to close the pipe
314-
to ``ffmpeg``. If not, Manim assumes that a static image should be output
313+
played -- and if so, it tells the :class:`.SceneFileWriter` to close the output
314+
file. If not, Manim assumes that a static image should be output
315315
which it then renders using the same strategy by calling the render loop
316316
(see below) once.
317317

@@ -762,10 +762,10 @@ to learn more, the :func:`.get_hash_from_play_call` function in the
762762
mechanism.
763763

764764
In the event that the animation has to be rendered, the renderer asks
765-
its :class:`.SceneFileWriter` to start a writing process. The process
766-
is started by a call to ``ffmpeg`` and opens a pipe to which rendered
767-
raw frames can be written. As long as the pipe is open, the process
768-
can be accessed via the ``writing_process`` attribute of the file writer.
765+
its :class:`.SceneFileWriter` to open an output container. The process
766+
is started by a call to ``libav`` and opens a container to which rendered
767+
raw frames can be written. As long as the output is open, the container
768+
can be accessed via the ``output_container`` attribute of the file writer.
769769
With the writing process in place, the renderer then asks the scene
770770
to "begin" the animations.
771771

@@ -815,7 +815,7 @@ time is extracted (3 seconds long) and stored in
815815
skip (it should not), then whether the animation is already
816816
cached (it is not). The corresponding animation hash value is
817817
determined and passed to the file writer, which then also calls
818-
``ffmpeg`` to start the writing process which waits for rendered
818+
``libav`` to start the writing process which waits for rendered
819819
frames from the library.
820820

821821
The scene then ``begin``\ s the animation: for the
@@ -1001,7 +1001,7 @@ and :meth:`.Animation.clean_up_from_scene` methods are called.
10011001
In the end, the time progression is closed (which completes the displayed progress bar)
10021002
in the terminal. With the closing of the time progression, the
10031003
:meth:`.Scene.play_internal` call is completed, and we return to the renderer,
1004-
which now orders the :class:`.SceneFileWriter` to close the movie pipe that has
1004+
which now orders the :class:`.SceneFileWriter` to close the output container that has
10051005
been opened for this animation: a partial movie file is written.
10061006

10071007
This pretty much concludes the walkthrough of a :class:`.Scene.play` call,

docs/source/installation.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ Installing Manim via Conda and related environment managers
3434
Conda is a package manager for Python that allows creating environments
3535
where all your dependencies are stored. Like this, you don't clutter up your PC with
3636
unwanted libraries and you can just delete the environment when you don't need it anymore.
37-
It is a good way to install manim since all dependencies like
38-
``ffmpeg``, ``pycairo``, etc. come with it.
37+
It is a good way to install manim since all dependencies like ``pycairo``, etc. come with it.
3938
Also, the installation steps are the same, no matter if you are
4039
on Windows, Linux, Intel Macs or on Apple Silicon.
4140

@@ -69,7 +68,7 @@ in order for Manim to work properly, some additional system
6968
dependencies need to be installed first. The following pages have
7069
operating system specific instructions for you to follow.
7170

72-
Manim requires Python version ``3.8`` or above to run.
71+
Manim requires Python version ``3.9`` or above to run.
7372

7473
.. hint::
7574

docs/source/installation/jupyter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ then execute it.
6666
.. code-block::
6767
6868
!sudo apt update
69-
!sudo apt install libcairo2-dev ffmpeg \
69+
!sudo apt install libcairo2-dev \
7070
texlive texlive-latex-extra texlive-fonts-extra \
7171
texlive-latex-recommended texlive-science \
7272
tipa libpango1.0-dev

0 commit comments

Comments
 (0)