Coder Social home page Coder Social logo

Comments (9)

willperkins avatar willperkins commented on May 20, 2024

I am experiencing a similar issue

In [3]: movie.to_videofile("final.mp4", codec="mpeg4")
Making file final.mp4 ...
Rendering audio TEMP_MPY_to_videofile_SOUND.ogg
===========Error: wrong indices in video buffer. Maybe buffer too small.
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-3-1fd66c2da9ef> in <module>()
----> 1 movie.to_videofile("final.mp4", codec="mpeg4")

/usr/local/lib/python2.7/site-packages/moviepy/video/VideoClip.pyc in to_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, para, verbose)
    271             if make_audio:
    272                 self.audio.to_audiofile(temp_audiofile,audio_fps, audio_nbytes,
--> 273                     audio_bufsize, audio_codec, audio_bitrate, verbose)
    274             ffmpeg_writer.ffmpeg_write(self, videofile, fps, codec,
    275                                        bitrate=bitrate, verbose=verbose)

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_audiofile(self, filename, fps, nbytes, buffersize, codec, bitrate, verbose)

/usr/local/lib/python2.7/site-packages/moviepy/decorators.pyc in requires_duration(f, clip, *a, **k)
     41         raise ValueError("Attribute 'duration' not set")
     42     else:
---> 43         return f(clip, *a, **k)
     44 
     45 @decorator.decorator

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_audiofile(self, filename, fps, nbytes, buffersize, codec, bitrate, verbose)
     79 
     80         return ffmpeg_audiowrite(self,filename, fps, nbytes, buffersize,
---> 81                       codec, bitrate, verbose)
     82 
     83 try:

/usr/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py in ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize, codec, bitrate, verbose)

/usr/local/lib/python2.7/site-packages/moviepy/decorators.pyc in requires_duration(f, clip, *a, **k)
     41         raise ValueError("Attribute 'duration' not set")
     42     else:
---> 43         return f(clip, *a, **k)
     44 
     45 @decorator.decorator

/usr/local/lib/python2.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py in ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize, codec, bitrate, verbose)
     86         if ( (i% ifeedback) == 0): verbose_print("=")
     87         tt = (1.0/fps)*np.arange(pospos[i],pospos[i+1])
---> 88         sndarray = clip.to_soundarray(tt,nbytes)
     89         writer.write_frames(sndarray)
     90 

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_soundarray(self, tt, fps, nbytes)

/usr/local/lib/python2.7/site-packages/moviepy/decorators.pyc in requires_duration(f, clip, *a, **k)
     41         raise ValueError("Attribute 'duration' not set")
     42     else:
---> 43         return f(clip, *a, **k)
     44 
     45 @decorator.decorator

/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.pyc in to_soundarray(self, tt, fps, nbytes)
     63             tt = np.arange(0,self.duration, 1.0/fps)
     64 
---> 65         snd_array = self.get_frame(tt)
     66         snd_array = np.maximum(-0.999, np.minimum(0.999,snd_array))
     67         inttype = {1:'int8',2:'int16',4:'int32'}[nbytes]

/usr/local/lib/python2.7/site-packages/moviepy/audio/io/AudioFileClip.pyc in gf(t)
     69 
     70                 try:
---> 71                     result[in_time] = self.buffer[inds - self._fstart_buffer]
     72                     return result
     73                 except:

IndexError: index 99963 is out of bounds for axis 0 with size 99963

from moviepy.

jamiewannenburg avatar jamiewannenburg commented on May 20, 2024

I am also experiencing the same issue.

audio_clip = AudioFileClip(clip_path,buffersize=200000000)
audio_clip.to_soundarray(fps=44100)

Error: wrong indices in video buffer. Maybe buffer too small.
Traceback (most recent call last):
  File "C:\Users\Vincent\Programming\Bridgestone\post.py", line 45, in <module>   np.save(path_no_extension, audio_clip.to_soundarray(fps=sr))
  File "<string>", line 2, in to_soundarray
  File "C:\Python27\lib\site-packages\moviepy-0.2.1.6.94-py2.7.egg\moviepy\decorators.py", line 47, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python27\lib\site-packages\moviepy-0.2.1.6.94-py2.7.egg\moviepy\audio\AudioClip.py", line 65, in to_soundarray
    snd_array = self.get_frame(tt)
  File "C:\Python27\lib\site-packages\moviepy-0.2.1.6.94 py2.7.egg\moviepy\audio\io\AudioFileClip.py", line 71, in gf
    result[in_time] = self.buffer[inds - self._fstart_buffer]
IndexError: index (393248) out of range (0<=index<393244) in dimension 0

It makes no difference how large I make the buffersize or how small the fps. Any ideas?
(Note: This error is from my windows 7 machine, but it is the same on ubuntu.)

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

Thanks you three for the feedback.
@karpitsky : What you are describing seems to be a bug in the "rewind" which I am investigating (but I am a little busy with other stuffs so it might take a few days). For instance, I get a bug with the following:

clip = VideoFileClip('myvideo.mp4')
clip.to_videofile("test1.mp4")
clip.to_videofile("test2.mp4")

This is because clip is read once entirely to make test1.mp4, then there is a rewind (cursor set to 0 again) when I ask to make test2.mp4 and for some reasons the rewind is buggy so the third line will fail. Until this is repared, you can solve this by making several rentry points to the file:

clip1 = VideoFileClip('myvideo.mp4')
clip2 = VideoFileClip('myvideo.mp4')
clip1.to_videofile("test1.mp4")
clip2.to_videofile("test2.mp4")

@willperkins : I would need some more details, but my guess is that your issue (and its current solution) would be the same as for karpitsky.

@jamiewannenburg : strange bug, maybe not related to the other's. I will see what I can do. How long lasts your sound ?

from moviepy.

jamiewannenburg avatar jamiewannenburg commented on May 20, 2024

Hi @Zulko, thanks for the reply. I think you are right.
If I make the buffersize = 150000000 I stop getting the error for most of my files; however then I get a MemoryError for the biggest ones. So guess it's time to upgrade to python64 and/or my hardware.

The largest file is around 3min HD footage.

I am trying to automate the batch syncing and editing of a gopro camera array for a bullet time effect. I want to get the audio of at least two files into numpy arrays so I can do a scipy.signal.fftconvolve with them. But I keep running into memory problems (even if I import using scipy.io.wavfile). So I am checking out numpy.memmap as a solution or using a much lower sample rate or both.

Edit1:
Actually, since I am adding a lot of files it might be related to another problem I have that is strictly a windows problem. I receive this error whenever I use a reader:

Traceback (most recent call last):
  File "C:\Users\Vincent\Programming\Bridgestone\sync_audio.py", line 7, in <module>
    clip1 = VideoFileClip("2014-01-29 16.44.00.mp4", audio=True)
  File "C:\Python27\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 46, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
  File "C:\Python27\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 17, in __init__
    self.load_infos(print_infos)
  File "C:\Python27\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 44, in load_infos
    proc.terminate()
  File "C:\Python27\lib\subprocess.py", line 1016, in terminate
    _subprocess.TerminateProcess(self._handle, 1)
WindowsError: [Error 5] Access is denied

Google pointed me to http://bugs.python.org/issue14252 . So I thought the subprocess was already terminated when the error gets raised, and therefore there would be no harm in excepting a WindowsError every time a process is terminated. I guess not... Since I also received buffer/memory issues on my Ubuntu machine I thought the problems where unrelated. But my Ubuntu machine has only 1GB of RAM. I'll try to upgrade python and see if that helps.

Edit2:
Updated python => no more windows errors.

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

@karpitsky @willperkins I think I have fixed this bug (only on Github, didn't push to Pypi yet). You'll tell me.

from moviepy.

willperkins avatar willperkins commented on May 20, 2024

thanks @Zulko . I can update and test again. As a workaround, I found that if I worked with a smaller segment of the movie, I didn't encounter the error. The original movie I was editing is about 4 minutes long.

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

@karpitsky @willperkins @jamiewannenburg
In case you are still interested, I believe I fixed this audio issue while working on another one. It seems pretty stable now. If some of you want to try it again, I would be very grateful to receive feedback !

from moviepy.

willperkins avatar willperkins commented on May 20, 2024

@Zulko this fixed the issue for me. Thanks for the update!

from moviepy.

Zulko avatar Zulko commented on May 20, 2024

This is old, many things changed since then. I'm closing the issue. Open a new one if you still have problems.

from moviepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.