Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.09k stars 1.51k forks source link

too many command-line calls to the ffmpeg binary ? #2051

Open Goyet-Christopher opened 8 months ago

Goyet-Christopher commented 8 months ago

I have the impression that MoviePy makes far too many command-line calls to the ffmpeg binary, and this significantly slows down file creation and writing. For example, I tested applying 'myclip.time_transform(lambda t: 3-t)' as shown in the source code (clip.py). To verify this, you can add a 'print(cmd)' statement in the 'subprocess.Popen' init function. Thus, observations reveal that this occurs with each frame :

frame_index: 0%| | 2/2494 [00:00<04:11, 9.91it/s, now=None]['ffmpeg-osx64-v4.2.2', '-ss', '3.983317', '-i', 'IMG_5950.m4v', '-ss', '1.000000', '-loglevel', 'error', '-f', 'image2pipe', '-vf', 'scale=2160:3840', '-sws_flags', 'bicubic', '-pix_fmt', 'rgb24', '-vcodec', 'rawvideo', '-'] frame_index: 0%| | 3/2494 [00:03<52:02, 1.25s/it, now=None]['ffmpeg-osx64-v4.2.2', '-ss', '3.966633', '-i', 'IMG_5950.m4v', '-ss', '1.000000', '-loglevel', 'error', '-f', 'image2pipe', '-vf', 'scale=2160:3840', '-sws_flags', 'bicubic', '-pix_fmt', 'rgb24', '-vcodec', 'rawvideo', '-'] ... ... ...

Is it possible or feasible to save all the frames of the video in a variable when opening the file? In order to minimize the calls to ffmpeg to just one ...