moviepy icon indicating copy to clipboard operation
moviepy copied to clipboard

Simple GIF from zipped

Open enzyme69 opened this issue 9 years ago • 9 comments

While looking for Python image sequence to GIF, I stumbled into your moviepy module: http://zulko.github.io/blog/2014/01/23/making-animated-gifs-from-video-files-with-python/

I tested using MP4 and MOV seems to work perfectly.

However, rather than to create MOV using Quicktime or Blender each time, is there a simpler way to skip the video to GIF, but instead to work from ZIP or Folder Path, to get all the files in sequence and generate GIF?

Thanks!

enzyme69 avatar Apr 30 '16 09:04 enzyme69

use

clip = ImageSequenceClip(my_path, fps=20)

where my_path contains the images in the right order.

Zulko avatar Apr 30 '16 09:04 Zulko

I keep getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jimmygunawan/anaconda/envs/py35/lib/python3.5/site-packages/moviepy/video/io/ImageSequenceClip.py", line 104, in **init**
    if with_mask and (make_frame(0).shape[2]==4):
  File "/Users/jimmygunawan/anaconda/envs/py35/lib/python3.5/site-packages/moviepy/video/io/ImageSequenceClip.py", line 99, in make_frame
    self.lastimage = imread(self.sequence[index])[:,:,:3] 
  File "/Users/jimmygunawan/anaconda/envs/py35/lib/python3.5/site-packages/imageio/core/functions.py", line 181, in imread
    reader = read(uri, format, 'i', **kwargs)
  File "/Users/jimmygunawan/anaconda/envs/py35/lib/python3.5/site-packages/imageio/core/functions.py", line 108, in get_reader
    'in mode %r' % mode)
ValueError: Could not find a format to read the specified file in mode 'i'

Wonder that's because the image sequences are PNGs output from Blender?

enzyme69 avatar Aug 29 '16 05:08 enzyme69

Linking this to #219, which is about the same error.

keikoro avatar Feb 18 '17 00:02 keikoro

I'm having this problem too, and it's been more than one year since this issue is first addressed, is anyone maintaining moviepy?

Nick-Zhang1996 avatar Jul 30 '17 13:07 Nick-Zhang1996

Can you explain what your problem is ? are you also using Blender ?

Zulko avatar Jul 30 '17 13:07 Zulko

My apologizes, after some debugging I realized the problem does not lie in moviepy.

I'm not sure whether this would help anybody, but here's the cause of my problem: I was calling imread() on a file that is not a picture.

here's my stack:

 File "video.py", line 27, in <module>
    main()
  File "video.py", line 22, in main
    clip = ImageSequenceClip(args.image_folder, fps=args.fps)
  File "/root/miniconda3/envs/carnd/lib/python3.6/site-
packages/moviepy/video/io/ImageSequenceClip.py", line 106, in __init__
    if with_mask and (imread(self.sequence[0]).shape[2]==4):
  File "/root/miniconda3/envs/carnd/lib/python3.6/site-packages/imageio/core/functions.py", line 
185, in imread
    reader = read(uri, format, 'i', **kwargs)
  File "/root/miniconda3/envs/carnd/lib/python3.6/site-packages/imageio/core/functions.py", line 
108, in get_reader
    'in mode %r' % mode)
ValueError: Could not find a format to read the specified file in mode 'i'

which resembles this line from @enzyme69 's call stack self.lastimage = imread(self.sequence[index])[:,:,:3]

So I guess there may be a connection.

I was trying to make a video from pictures in a folder. I forgot there's a .DS_Store file automatically generated in that folder along with all the picture. This file got picked up by moviepy and caused the problem.

Nick-Zhang1996 avatar Jul 30 '17 14:07 Nick-Zhang1996

@enzyme69 Does the problem persist?

keikoro avatar Nov 25 '17 17:11 keikoro

I'd say that this should be fixed. I suggest putting more checks in ImageSequenceClip to ensure that (particularly when passing in a folder name) no non-images are loaded. This can catch people out because sometimes there are hidden files (such as .DS_Store on Mac) that cause it to crash.

tburrows13 avatar May 10 '20 16:05 tburrows13

@tburrows13 can you assign this to me?

pioneerHitesh avatar Oct 17 '23 07:10 pioneerHitesh