1

I'm trying to make a video from a list of images using moviepy. I have issues using moviepy.editor since it does not like being frozen using PyInstaller, so I'm using moviepy.video.VideoClip.ImageClip for the images and moviepy.video.compositing.CompositeVideoClip.CompositeVideoClip for the clip. I have a list of .jpg images in a list called images:

from moviepy.video.VideoClip import ImageClip
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip

clips = [ImageClip(m).set_duration(1) for m in images]
concat_clip = CompositeVideoClip(clips))
concat_clip.write_videofile('VIDEO.mp4', fps=1)

It successfully makes an .mp4 but the video is only one second long and the last image in the list of images. I can check clips and it has the ~30 images that should be in the video. I can do this from using methods from moviepy.editor following this SO question and answer, but there doesn't seem to be an analogous parameter in CompositeVideoClip for method='compose' which is where I think the issue is.

TheStrangeQuark
  • 2,257
  • 5
  • 31
  • 58
  • set_duration is set to 1? and why is your fps1? If you just deal wth images, ffmpeg does a much better and faster job: https://stackoverflow.com/questions/24961127/ffmpeg-create-video-from-images – user1767754 Nov 22 '17 at 18:57
  • I know ffmpeg would be better, but I cannot use it at my work. I have `set_duration` and `fps` set to 1 because each image should be shown for 1 second and the video will be at 1 fps just to make the file size as small as possible. – TheStrangeQuark Nov 22 '17 at 19:03

1 Answers1

0

using concatenate_videoclips might help. I use the code below and it works just fine.

clips = [ImageClip(m).set_duration(1/25)
         for m in file_list_sorted]
concat_clip = concatenate_videoclips(clips, method="compose")
concat_clip.write_videofile("test.mp4", fps=25)
mrr67man
  • 85
  • 2
  • 8
Yusra Shahid
  • 104
  • 9