manim icon indicating copy to clipboard operation
manim copied to clipboard

feat(lib): add basic VideoMobject class

Open jeertmans opened this issue 2 years ago • 8 comments

Hello, I actually implemented this for a personal need, but I guess other people could enjoy such feature, as in #760.

The current implementation is very minimalist, and may be improved, or tested / better documented.

If OpenCV is added as a dependency, then we could also directly load videos from video files, which could be a nice feature.

jeertmans avatar Dec 05 '23 18:12 jeertmans

Thanks for the proposal, this looks like a good idea -- and we do get requests for this reasonably often indeed.

I'd be somewhat unhappy with adding OpenCV as a new dependency (we're currently rather trying to reduce dependencies), and OpenCV is not a particularly lightweight one either. However, it should be possible to achieve similar things with the ffmpeg bindings for Python, and as ffmpeg is a dependency already, adding the Python bindings would not hurt too much.

behackl avatar Dec 05 '23 20:12 behackl

Something like that https://github.com/kkroening/ffmpeg-python/blob/master/examples/ffmpeg-numpy.ipynb?

it seems quite easy to load all frames into one large array

jeertmans avatar Dec 06 '23 06:12 jeertmans

Instead of the ffmpeg python bindings it is possible that we finally tackle #442 and include av as a dependency. It would be similarly easy with that.

behackl avatar Dec 06 '23 08:12 behackl

Instead of the ffmpeg python bindings it is possible that we finally tackle #442 and include av as a dependency. It would be similarly easy with that.

Oh! That's a super nice feature if we support av :D I might try to implement this later this month :-)

jeertmans avatar Dec 06 '23 09:12 jeertmans

@behackl looks like the av module is quite heavy, maybe it already includes ffmpeg https://pypi.org/project/av/11.0.0/#files?

I don't know how to interpret (from their READMDE):

Due to the complexity of the dependencies, PyAV is not always the easiest Python package to > install from source. Since release 8.0.0 binary wheels are provided on [PyPI][pypi] for Linux, Mac and Windows linked against a modern FFmpeg. You can install these wheels by running:

pip install av

If you want to use your existing FFmpeg, the source version of PyAV is on [PyPI][pypi] too:

pip install av --no-binary av

jeertmans avatar Dec 06 '23 12:12 jeertmans

@behackl looks like the av module is quite heavy, maybe it already includes ffmpeg https://pypi.org/project/av/11.0.0/#files?

I don't know how to interpret (from their READMDE):

Haha, fun to see that you ran into the exact same question as I did. :-)

From my current understanding: yes, they provide wheels which include a statically linked version of ffmpeg (which would be actually amazing for us as it eliminates the biggest pain point about installing manim for our users).

I have planned to investigate in more detail over the coming days, perhaps we are in luck.

behackl avatar Dec 06 '23 13:12 behackl

Let’s see how much it can improve the speed, the thing I am the most interested in!

jeertmans avatar Dec 06 '23 22:12 jeertmans

Related PR: https://github.com/ManimCommunity/manim/pull/3501

chopan050 avatar Dec 09 '23 20:12 chopan050