Error: wrong indices in video buffer. Maybe buffer too small.
See original GitHub issueThe following code:
wordSlide = ColorClip((1280,720), (228,232,111))
wordText = TextClip(wordStr, font="Arial-Regular", color="YellowGreen", fontsize=90)
wordAudio = AudioFileClip(path + "word.aif")
wordClip = CompositeVideoClip([wordSlide.set_audio(wordAudio),
wordText.set_pos('center')]).set_duration(wordAudio.duration)
Produces:
Error: wrong indices in video buffer. Maybe buffer too small.
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "<string>", line 2, in preview
File "/usr/local/lib/python2.7/site-packages/moviepy/decorators.py", line 60, in requires_duration
return f(clip, *a, **k)
File "/usr/local/lib/python2.7/site-packages/moviepy/audio/io/preview.py", line 59, in preview
sndarray = clip.to_soundarray(tt,nbytes)
File "<string>", line 2, in to_soundarray
File "/usr/local/lib/python2.7/site-packages/moviepy/decorators.py", line 60, in requires_duration
return f(clip, *a, **k)
File "/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.py", line 83, in to_soundarray
snd_array = self.get_frame(tt)
File "/usr/local/lib/python2.7/site-packages/moviepy/audio/AudioClip.py", line 189, in get_frame
if (part is not False) ]
File "/usr/local/lib/python2.7/site-packages/moviepy/audio/io/AudioFileClip.py", line 69, in <lambda>
self.get_frame = lambda t: self.reader.get_frame(t)
File "/usr/local/lib/python2.7/site-packages/moviepy/audio/io/readers.py", line 173, in get_frame
raise error
IndexError: index 45785 is out of bounds for axis 0 with size 45784
A little hack that kinda makes it go away is to do:
wordSlide = ColorClip((1280,720), (228,232,111))
wordText = TextClip(wordStr, font="Arial-Regular", color="YellowGreen", fontsize=90)
wordAudio = AudioFileClip(path + "word.aif")
wordClip = CompositeVideoClip([wordSlide.set_audio(wordAudio),
wordText.set_pos('center')]).set_duration(wordAudio.duration - 0.01)
Although this doesn’t fix anything. It just happens to work in this case, but not for other clips. Why is it crashing?
The wordAudio.duration is 1.04s in this case. On some audio files it crashes, on some it doesn’t. Is this the accuracy problem with generating number of frames based on audio length?
Issue Analytics
- State:
- Created 9 years ago
- Comments:38 (15 by maintainers)
Top Results From Across the Web
HTML5 Video buffered attribute features - Stack Overflow
But I am seeking only 3 portions, it seems too small a number to start clearing the cache. And no, the resulting single...
Read more >Video - Bad buffer index: -10000 - Unity Forum
I thought it has something to do with setting the wrong frame (too big or too small frame index that doesn't exist because...
Read more >WebGL 2 Uniform Buffer Objects size inconsistent on Mac and ...
"Error: WebGL warning: drawElements: Buffer for uniform block is smaller than UNIFORM_BLOCK_DATA_SIZE." According to the ES 3.0 spec: If pname is ...
Read more >3.6. Buffers — The Linux Kernel documentation
Additionally, drivers shall return a EINVAL error from the VIDIOC_QBUF() ioctl if the buffer being queued is too small for the current format...
Read more >What is buffering on TV? - SkyLine/SkyBest
Possibly the most common form of buffering occurs when your internet speed is ... The final problem you may have that is causing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
First, an update on your bugs.
At least on my computer, it seems that the main problem is that you ask the same clip to play three times, which forces the ffmpeg-reader to “rewind” or re-initialize, and that’s where the bug happens. You so that it is clearer:
I will try to see what causes this bug. In the meantime, the most reliable solution is to create different entry points into the file:
Since you need to process these clips afterwards, the best thing to do is to make a loop or a function, like this:
I have ran a couple hundred renderings, and I can confirm the bug is definitely fixed. Thank you very much! You’re awesome.