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

to_soundarray Index error #1034

Closed
benjamin-weller opened this issue Nov 5, 2019 · 2 comments
Closed

to_soundarray Index error #1034

benjamin-weller opened this issue Nov 5, 2019 · 2 comments

Comments

@benjamin-weller
Copy link

Expected Behavior

to_soundarray will return return an array with ~8430 elements in it.

Actual Behavior

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~\Anaconda3\lib\site-packages\moviepy\audio\io\readers.py in get_frame(self, tt)
    192                 return result
--> 193 
    194             except IndexError as error:

IndexError: index -12300920 is out of bounds for axis 0 with size 100744

During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
<ipython-input-5-c0a1e02bcddd> in <module>()
      4 clip = VideoFileClip(r"C:\Users\BenjaminWeller\Documents\movie_try\media\video_with_failing_audio.mp4")
      5 
----> 6 array = clip.audio.to_soundarray(fps=30)

<decorator-gen-197> in to_soundarray(self, tt, fps, quantize, nbytes, buffersize)

~\Anaconda3\lib\site-packages\moviepy\decorators.py in requires_duration(f, clip, *a, **k)
     52         raise ValueError("Attribute 'duration' not set")
     53     else:
---> 54         return f(clip, *a, **k)
     55 
     56 

~\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py in to_soundarray(self, tt, fps, quantize, nbytes, buffersize)
    124         #print tt.max() - tt.min(), tt.min(), tt.max()
    125 
--> 126         snd_array = self.get_frame(tt)
    127 
    128         if quantize:

<decorator-gen-135> in get_frame(self, t)

~\Anaconda3\lib\site-packages\moviepy\decorators.py in wrapper(f, *a, **kw)
     87         new_kw = {k: fun(v) if k in varnames else v
     88                  for (k,v) in kw.items()}
---> 89         return f(*new_a, **new_kw)
     90     return decorator.decorator(wrapper)
     91 

~\Anaconda3\lib\site-packages\moviepy\Clip.py in get_frame(self, t)
     93                 return frame
     94         else:
---> 95             return self.make_frame(t)
     96 
     97     def fl(self, fun, apply_to=None, keep_duration=True):

~\Anaconda3\lib\site-packages\moviepy\audio\io\AudioFileClip.py in <lambda>(t)
     76         self.buffersize = self.reader.buffersize
     77 
---> 78         self.make_frame = lambda t: self.reader.get_frame(t)
     79         self.nchannels = self.reader.nchannels
     80 

~\Anaconda3\lib\site-packages\moviepy\audio\io\readers.py in get_frame(self, tt)
    203                 result[in_time] = self.buffer[indices]
    204                 return result
--> 205 
    206         else:
    207 

IndexError: index -12300920 is out of bounds for axis 0 with size 100744 

Steps to Reproduce the Problem

import numpy as np # for numerical operations
from moviepy.editor import VideoFileClip, concatenate_videoclips
clip = VideoFileClip(r"PATH_TO_MEDIA_DIRECTORY/video_with_failing_audio.mp4")
array = clip.audio.to_soundarray(fps=30)

Specifications

  • Python Version: 3.7
  • Moviepy Version: 1.0.1
  • Platform Name: Windows
  • Platform Version: 10
@benjamin-weller
Copy link
Author

I've also tried this on 1.0.0 as that was a recommendation on a different thread (the number escapes me).

The file I'm testing against is MOVIEPY_DIR/media/video_with_failing_audio.mp4

@benjamin-weller
Copy link
Author

It appears that this is just an issue of a confusing parameter name. I thought FPS ment FPS for the video, what it really means is the hertz of the audio in this situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant