Zulko / moviepy

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

AudioFileClip.cutout produces a out of bounds error if the cutout is over a certain length #1760

Open Nick-Lit opened 2 years ago

Nick-Lit commented 2 years ago

When attempting to run the following code, I'm given "IndexError: index -342999 is out of bounds for axis 0 with size 200000" if I change the 45 in the audio_clip.cutout function to a lower number like 40, the code runs as expected.

video_clip = VideoFileClip(filename='example.mp4')
audio_clip = video_clip.audio
audio_clip = audio_clip.cutout(35, 45)
final_clip = video_clip.set_audio(audio_clip)
final_clip.write_videofile("example_fixed.mp4")

Expected Behavior

The code would produce a clip with the audio removed from the time 0:35 to 0:45.

Actual Behavior

The code produces an Index error.

Specifications

Nick-Lit commented 2 years ago

I applied the changes to the readers.py file proposed in #1757 and it appears to have fixed the issue. Until it is merged into the main branch, this seems to be the only solution.

keikoro commented 2 years ago

@Nick-Lit Thanks for the update, I've linked your issue to the PR in question.