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

Concatenation of moviepy.audio.AudioClip.CompositeAudioClip instances #2228

Open
Mathemilda opened this issue Oct 13, 2024 · 3 comments
Open
Labels
bug Issues that report (apparent) bugs.

Comments

@Mathemilda
Copy link

Expected Behavior

I want to create a composed Audio.AudioClip instance to attach to my video. I have a method to create notes from frequences, they are concatenated together as a chime, and then I want to use the chimes separated by silence periods for my video.

Actual Behavior

Concatenation of moviepy.audio.AudioClip.CompositeAudioClip instance list produces an error.

Steps to Reproduce the Problem

My code, with my method for chime creation. It uses concatenate_audioclips().

texts = chime_dict.keys()
trial_chimes = []
for txt in texts:
    audioClip = mm.chime_clip(chime_dict[txt]['freq'],
                                      periods=chime_dict[txt]['periods'])
    print(audioClip.duration)
    trial_chimes.append(trial_chimes)

trial_chimes_concat = concatenate_audioclips(trial_chimes)

Here what I see in my console as output:

<class 'moviepy.audio.AudioClip.CompositeAudioClip'>
1.0
<class 'moviepy.audio.AudioClip.CompositeAudioClip'>
1.0
<class 'moviepy.audio.AudioClip.CompositeAudioClip'>
1.0
Traceback (most recent call last):

  Cell In[8], line 11
    trial_chimes_concat = concatenate_audioclips(trial_chimes)

  File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\moviepy\audio\AudioClip.py:315 in concatenate_audioclips
    durations = [c.duration for c in clips]

AttributeError: 'list' object has no attribute 'duration'

Specifications

  • Python Version: 3.12.4
  • MoviePy Version: pip show moviePy
  • Platform Name: Microsoft Widows 11 Pro
  • Platform Version: 10.0.22631 Build 11631
@Mathemilda Mathemilda added the bug Issues that report (apparent) bugs. label Oct 13, 2024
@steinathan
Copy link

your example code looks a bit off, you mean .extend()

trial_chimes.append(trial_chimes)

@Mathemilda
Copy link
Author

@steinathan
Copy link

Yes.

image

You're appending trial_chimes back to itself and then concatenating it, some items in trial_chimes wont be Clip but rather Clip | List

look at your indent, you should append audioClip not trial_chimes

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.
Projects
None yet
Development

No branches or pull requests

2 participants