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

Deprecation warnings #1338

Closed
tburrows13 opened this issue Oct 8, 2020 · 8 comments · Fixed by #1443
Closed

Deprecation warnings #1338

tburrows13 opened this issue Oct 8, 2020 · 8 comments · Fixed by #1443
Assignees
Labels
bug Issues that report (apparent) bugs. good-first-issue Especially suitable for people new to moviepy and/or programming; beginner-friendly.

Comments

@tburrows13
Copy link
Collaborator

tburrows13 commented Oct 8, 2020

When running the test suite it reveals some deprecations:

  /home/runner/work/moviepy/moviepy/moviepy/audio/AudioClip.py:121: FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.

  /home/runner/work/moviepy/moviepy/moviepy/video/io/gif_writers.py:323: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.

Source: https://github.com/Zulko/moviepy/runs/1227641497 (under PyTest)
I think that the first one is NumPy and the second is Pillow (PIL).

It would be good to investigate and fix these 2 warnings.

@tburrows13 tburrows13 added bug Issues that report (apparent) bugs. good-first-issue Especially suitable for people new to moviepy and/or programming; beginner-friendly. labels Oct 8, 2020
@tburrows13 tburrows13 added this to the Release v2.0.0 milestone Oct 8, 2020
@somstrom
Copy link
Contributor

somstrom commented Oct 8, 2020

@tburrows13

Could you please assign this to me ?

fkr-0 added a commit to fkr-0/moviepy that referenced this issue Oct 15, 2020
- s/frame.tostring()/frame.tobytes()
- replace generator as source for numpy stacks with a list
somstrom added a commit to somstrom/moviepy that referenced this issue Oct 25, 2020
@mondeja mondeja self-assigned this Jan 14, 2021
@vincenzoml
Copy link

vincenzoml commented Aug 6, 2023

@tburrows13 I do have an "arrays to stack must be passed as 'sequence' type" error which I did not have before, with moviepy 1.0.3, when muxing audio and video (saving the video); isn't this merged? Now it's no longer a warning and the code fails.

TypeError                                 Traceback (most recent call last)
/workspaces/animachines-ai/home/vincenzo/projects/kitchen/kitchen.py in line 3
      [34](file:///workspaces/animachines-ai/home/vincenzo/projects/kitchen/kitchen.py?line=33) # %% audio
----> [36](file:///workspaces/animachines-ai/home/vincenzo/projects/kitchen/kitchen.py?line=35) master_track = sonica.load_audio("music/kitchen 2023-08-06 2312.mp3")

File /workspaces/animachines-ai/home/vincenzo/anima/sonica.py:110, in load_audio(filename, mono)
    [108](file:///workspaces/animachines-ai/home/vincenzo/anima/sonica.py?line=107) clip = mpy.AudioFileClip(filename)
    [109](file:///workspaces/animachines-ai/home/vincenzo/anima/sonica.py?line=108) fn = clip.get_frame
--> [110](file:///workspaces/animachines-ai/home/vincenzo/anima/sonica.py?line=109) vector = clip.to_soundarray(fps=clip.fps)
    [111](file:///workspaces/animachines-ai/home/vincenzo/anima/sonica.py?line=110) if mono:
    [112](file:///workspaces/animachines-ai/home/vincenzo/anima/sonica.py?line=111)     def fn(t): return np.average(clip.get_frame(t))

File :2, in to_soundarray(self, tt, fps, quantize, nbytes, buffersize)

File /usr/local/lib/python3.10/dist-packages/moviepy/decorators.py:54, in requires_duration(f, clip, *a, **k)
     [52](file:///usr/local/lib/python3.10/dist-packages/moviepy/decorators.py?line=51)     raise ValueError("Attribute 'duration' not set")
     [53](file:///usr/local/lib/python3.10/dist-packages/moviepy/decorators.py?line=52) else:
---> [54](file:///usr/local/lib/python3.10/dist-packages/moviepy/decorators.py?line=53)     return f(clip, *a, **k)

File /usr/local/lib/python3.10/dist-packages/moviepy/audio/AudioClip.py:113, in AudioClip.to_soundarray(self, tt, fps, quantize, nbytes, buffersize)
    [111](file:///usr/local/lib/python3.10/dist-packages/moviepy/audio/AudioClip.py?line=110) if tt is None:
    [112](file:///usr/local/lib/python3.10/dist-packages/moviepy/audio/AudioClip.py?line=111)     if self.duration > max_duration:
--> [113](file:///usr/local/lib/python3.10/dist-packages/moviepy/audio/AudioClip.py?line=112)         return stacker(self.iter_chunks(fps=fps, quantize=quantize,
    [114](file:///usr/local/lib/python3.10/dist-packages/moviepy/audio/AudioClip.py?line=113)                                         nbytes=2, chunksize=buffersize))
    [115](file:///usr/local/lib/python3.10/dist-packages/moviepy/audio/AudioClip.py?line=114)     else:
    [116](file:///usr/local/lib/python3.10/dist-packages/moviepy/audio/AudioClip.py?line=115)         tt = np.arange(0, self.duration, 1.0/fps)

File [~/.local/lib/python3.10/site-packages/numpy/core/shape_base.py:216](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f76696e63656e7a6f2f646174612f6c6f63616c2f7265706f732f616e696d616368696e65732d6169222c226c6f63616c446f636b6572223a66616c73652c2273657474696e6773223a7b22686f7374223a227373683a2f2f70632d6369616e6369612e697374692e636e722e6974227d2c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f76696e63656e7a6f2f646174612f6c6f63616c2f7265706f732f616e696d616368696e65732d61692f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d.vscode-resource.vscode-cdn.net/workspaces/animachines-ai/home/vincenzo/projects/kitchen/~/.local/lib/python3.10/site-packages/numpy/core/shape_base.py:216), in _vhstack_dispatcher(tup, dtype, casting)
    [215](file:///home/animachines/.local/lib/python3.10/site-packages/numpy/core/shape_base.py?line=214) def _vhstack_dispatcher(tup, *, dtype=None, casting=None):
--> [216](file:///home/animachines/.local/lib/python3.10/site-packages/numpy/core/shape_base.py?line=215)     return _arrays_for_stack_dispatcher(tup)

File [~/.local/lib/python3.10/site-packages/numpy/core/shape_base.py:209](https://vscode-remote+dev-002dcontainer-002b7b22686f737450617468223a222f686f6d652f76696e63656e7a6f2f646174612f6c6f63616c2f7265706f732f616e696d616368696e65732d6169222c226c6f63616c446f636b6572223a66616c73652c2273657474696e6773223a7b22686f7374223a227373683a2f2f70632d6369616e6369612e697374692e636e722e6974227d2c22636f6e66696746696c65223a7b22246d6964223a312c2270617468223a222f686f6d652f76696e63656e7a6f2f646174612f6c6f63616c2f7265706f732f616e696d616368696e65732d61692f2e646576636f6e7461696e65722f646576636f6e7461696e65722e6a736f6e222c22736368656d65223a227673636f64652d66696c65486f7374227d7d.vscode-resource.vscode-cdn.net/workspaces/animachines-ai/home/vincenzo/projects/kitchen/~/.local/lib/python3.10/site-packages/numpy/core/shape_base.py:209), in _arrays_for_stack_dispatcher(arrays)
    [207](file:///home/animachines/.local/lib/python3.10/site-packages/numpy/core/shape_base.py?line=206) def _arrays_for_stack_dispatcher(arrays):
    [208](file:///home/animachines/.local/lib/python3.10/site-packages/numpy/core/shape_base.py?line=207)     if not hasattr(arrays, "__getitem__"):
--> [209](file:///home/animachines/.local/lib/python3.10/site-packages/numpy/core/shape_base.py?line=208)         raise TypeError('arrays to stack must be passed as a "sequence" type '
    [210](file:///home/animachines/.local/lib/python3.10/site-packages/numpy/core/shape_base.py?line=209)                         'such as list or tuple.')
    [212](file:///home/animachines/.local/lib/python3.10/site-packages/numpy/core/shape_base.py?line=211)     return tuple(arrays)

TypeError: arrays to stack must be passed as a "sequence" type such as list or tuple.

@hman009
Copy link

hman009 commented Nov 1, 2023

facing this issue while converting while running the to_soundarray() method
TypeError: arrays to stack must be passed as a "sequence" type such as list or tuple.

@vinitnalhe
Copy link

I was also facing the same issue, when using python3.11.

I tried using the earlier version of python ( python 3.8) and to_soundarray() ran successfully.

@tbrouns
Copy link

tbrouns commented Nov 29, 2023

For anyone stumbling on this like I did:

Installing moviepy from source ( 2.0.0.dev0 ) fixed this issue for me:

pip install git+https://github.com/Zulko/moviepy.git@bc8d1a831d2d1f61abfdf1779e8df95d523947a5

More info

The PR attached to this issue solved the problem: #1443

Sample code that is working now, but didn't work with moviepy==1.0.3:

load_path = "path/to/my/video.mp4"
video = VideoFileClip(load_path)
audio_data = video.audio.to_soundarray(fps=16000)

@agamm
Copy link

agamm commented Jan 14, 2024

pip install git+https://github.com/Zulko/moviepy.git@bc8d1a831d2d1f61abfdf1779e8df95d523947a5

Why is this not added to a release yet?

@SohamTilekar
Copy link

pip install git+https://github.com/Zulko/moviepy.git@bc8d1a831d2d1f61abfdf1779e8df95d523947a5

Why is this not added to a release yet?

Because The Zulko is Not Active and #2085.

@keikoro
Copy link
Collaborator

keikoro commented Feb 10, 2024

The above (linked) discussion is not relevant, we are not actively using discussions. See issue #1874 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs. good-first-issue Especially suitable for people new to moviepy and/or programming; beginner-friendly.
Projects
None yet
10 participants