Moviepy: Index is out of bounds - AudioFileClip

Created on 3 Apr 2017  路  6Comments  路  Source: Zulko/moviepy

Hello,

I am trying to create a VideoClip using:

initial_clip.write_videofile('initial.mp4', codec='mpeg4', fps=24, audio_codec='libmp3lame')

where initial_clip is my VideoClip. I am getting the following error:

File "/usr/local/lib/python3.6/site-packages/moviepy/audio/io/readers.py", line 187, in get_frame
    result[in_time] = self.buffer[indices]
IndexError: index 100197 is out of bounds for axis 0 with size 100197

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/pankit/Documents/python-workspace/ttv_v1/imageprocessing/make_video.py", line 272, in <module>
    sys.exit(make_video_from_file())
  File "/Users/pankit/Documents/python-workspace/ttv_v1/imageprocessing/make_video.py", line 249, in make_video_from_file
    create_animated_clip(sentence)
  File "/Users/pankit/Documents/python-workspace/ttv_v1/imageprocessing/make_video.py", line 152, in create_animated_clip
    initial_clip.write_videofile('initial.mp4', codec='mpeg4', fps=24, audio_codec='libmp3lame')
  File "<decorator-gen-51>", line 2, in write_videofile
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-50>", line 2, in write_videofile
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-49>", line 2, in write_videofile
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.6/site-packages/moviepy/video/VideoClip.py", line 330, in write_videofile
    verbose=verbose)
  File "<decorator-gen-73>", line 2, in write_audiofile
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 204, in write_audiofile
    verbose=verbose, ffmpeg_params=ffmpeg_params)
  File "<decorator-gen-70>", line 2, in ffmpeg_audiowrite
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py", line 167, in ffmpeg_audiowrite
    nbytes= nbytes, fps=fps):
  File "/usr/local/lib/python3.6/site-packages/tqdm/_tqdm.py", line 833, in __iter__
    for obj in iterable:
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 81, in generator
    buffersize=chunksize)
  File "<decorator-gen-72>", line 2, in to_soundarray
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 127, in to_soundarray
    snd_array = self.get_frame(tt)
  File "<decorator-gen-14>", line 2, in get_frame
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 136, in <lambda>
    newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 188, in <lambda>
    return self.fl(lambda gf, t: gf(t_func(t)), apply_to,
  File "<decorator-gen-14>", line 2, in get_frame
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 292, in make_frame
    for c,part in zip(self.clips, played_parts)
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/AudioClip.py", line 293, in <listcomp>
    if (part is not False) ]
  File "<decorator-gen-14>", line 2, in get_frame
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 136, in <lambda>
    newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 188, in <lambda>
    return self.fl(lambda gf, t: gf(t_func(t)), apply_to,
  File "<decorator-gen-14>", line 2, in get_frame
  File "/usr/local/lib/python3.6/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.6/site-packages/moviepy/Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/io/AudioFileClip.py", line 71, in <lambda>
    self.make_frame =  lambda t: reader.get_frame(t)
  File "/usr/local/lib/python3.6/site-packages/moviepy/audio/io/readers.py", line 193, in get_frame
    "but len(buffer)=%d\n"%(len(self.buffer))+ str(error))
OSError: Error in file initial1.mp4, At time t=13.61-13.61 seconds, indices wanted: 100000-100200, but len(buffer)=100197
index 100197 is out of bounds for axis 0 with size 100197

I looked at a bunch of issues in the past which say this has been resolved, but I am still encountering the same.

@Zulko your help will be appreciated. Thanks in advance.

bug

All 6 comments

Can you try using the version in the repo? I think this has been fixed. EDIT: Actually, #377 is a fix for this, and will be merged shortly. Wait until then, or locally use the repo from https://github.com/gyglim/moviepy (with the fixes in)

@pchheda can you try the version in the repo? if you don't know how, ask, and we can help you.

@earney Yup. It would be great if you can help me with that? What would be the best way to use this version?

@pchheda You can now install the equivalent of master via pip install --upgrade moviepy as all of the fixes to date have been rolled into Release v0.2.3.1

Can try out the latest release and report back on whether or not that resolved your issue?

Thanks!

@pchheda Has the latest build resolved your issue?

Thanks.

It worked well. I was giving it some time to ensure it doesn't pop up again. I tried it on a bunch of videos of different types and sizes. It seems fixed to me. Thanks everyone for helping. Closing the issue. Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PyB1l picture PyB1l  路  3Comments

Swiffers picture Swiffers  路  4Comments

Netherdrake picture Netherdrake  路  4Comments

Gicehajunior picture Gicehajunior  路  3Comments

skizzy picture skizzy  路  3Comments