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

TypeError: 'ImageClip' object is not iterable #824

Closed
ghost opened this issue Jul 3, 2018 · 5 comments
Closed

TypeError: 'ImageClip' object is not iterable #824

ghost opened this issue Jul 3, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented Jul 3, 2018

Expected Behavior

So, I'm trying to take a bunch of images in an "images" folder, turn them into ImageClips one by one, then put those clips together into a video slideshow.

Actual Behavior

I get the following error message: TypeError: 'ImageClip' object is not iterable

Steps to Reproduce the Problem

import os

#this makes a list of filenames in the "images" folder. It is confirmed working.
picsUsed = []
for (dirpath, dirnames, filenames) in os.walk('C:\yes\my\path\works\fine\project\images'):
    picsUsed.extend(filenames)

#this makes each item in the picsUsed list have the "images/" folder in the string representing its path. It is confirmed working.
for i in range(len(picsUsed)):
    picsUsed[i] = "images//" + picsUsed[i]

print(picsUsed)

imgClips = []

#this function is supposed to take each image specified by its own path/filename created above, and turn it into a usable video clip. This function is NOT working.
for le_clip in picsUsed:
    tempImgClip = ImageClip(le_clip).set_duration(5)
    imgClips.extend(tempImgClip)```

final_clip = concatenate_videoclips(imgClips)
final_clip.write_videofile("final.mp4", fps=24)

Specifications

  • Python Version: 3.6.4
  • Moviepy Version: 0.2.3.2
  • Platform Name: Windows 10 Home
  • Platform Version: Latest
@Zulko
Copy link
Owner

Zulko commented Jul 3, 2018

can you paste the full error ? It is unclear what line the error happens.

@ghost
Copy link
Author

ghost commented Jul 3, 2018

Sure! Here's the full error:

['images//niceimage1.jpg', "images//niceimage2.jpg", 'images//niceimage3.jpg', "images//niceimage4.jpg"]
Traceback (most recent call last):
  File "C:\im\censoring\my\path\for\security_reasons\againAgain.py", line 26, in <module>
    imgClips.extend(tempImgClip)
TypeError: 'ImageClip' object is not iterable
[Finished in 2.688s]```

So the error happens at or before ```imgClips.extend(tempImgClip)```, I think.

@tburrows13
Copy link
Collaborator

Hi! Can you update moviepy to the latest version and try again please?

@Zulko
Copy link
Owner

Zulko commented Jul 5, 2018

It's a simple Python error, you use imgClips.extend while you should use imgClips.append.

@ghost
Copy link
Author

ghost commented Jul 5, 2018

Ah, okay, thank you!

@ghost ghost closed this as completed Jul 8, 2018
This issue was closed.
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

2 participants