Skip to content
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

Efficiency Disparity Between MoviePy and FFmpeg #2165

Open
OtokoNoIzumi opened this issue Apr 27, 2024 · 1 comment
Open

Efficiency Disparity Between MoviePy and FFmpeg #2165

OtokoNoIzumi opened this issue Apr 27, 2024 · 1 comment
Labels
question Questions regarding functionality, usage

Comments

@OtokoNoIzumi
Copy link

I recently encountered a significant difference in processing time when extracting a 70-second clip from a video using different methods. Utilizing MoviePy's subclip and write_videofile functions took over 20 seconds to complete the task. In stark contrast, invoking FFmpeg through subprocess with the -c copy command on the same file and clip took merely milliseconds.
How can I achieve similar efficiency using MoviePy? Currently, I observe that writing at the original speed is approximately 90 iterations per second (it/s), but when I introduce final_duration to expedite the process, the speed drops drastically to just a few it/s, which is considerably slower.
If there is no way to enhance the speed, I would appreciate an explanation of the design philosophy and benefits behind MoviePy's chosen architecture. Specifically, what are the intended advantages of this approach?

here is the python code demo
clip = VideoFileClip(video_paths[0]).subclip(0, 70) clip.write_videofile("my_new_video.mp4")

here is the subprocess params for FFmpeg
cmd=[ ffmpeg_path, '-i', input_video_path, '-c', 'copy', '-map', '0','-ss',str(start_time) , '-t', str(duration), '-q:v', '0', output_video_path,'-y', ]

@OtokoNoIzumi OtokoNoIzumi added the question Questions regarding functionality, usage label Apr 27, 2024
@bzczb
Copy link

bzczb commented May 21, 2024

There's a performance problem in recent versions of moviepy, because of the way some decorators were implemented: #2094

If you patch that, you might not be able to get -c copy performance, but it'll be much improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions regarding functionality, usage
Projects
None yet
Development

No branches or pull requests

2 participants