1

I need to create a video by selecting a series of images in folder and add music to the video. With the below approach, I'm able to generate the video but unable to iterate the images while the video is running.

for filename in os.listdir("E://images"):
  if filename.endswith(".png"):
    clips.append(ImageClip("E://images//"+filename).set_duration(8))
 finalVideo = CompositeVideoClip( clips ).set_duration(8)

slides=[finalVideo]

final = CompositeVideoClip(slides, size=(100,200)).set_duration(8)

audioclip = AudioFileClip("E://songs//new.mp3")
videoclip2 = final.set_audio(audioclip)
videoclip2.write_videofile("test.mp4",fps=24)

I tried with this link as well Convert image sequence to video using Moviepy instead of using CompositeVideoClip i tried with

 concat_clip = concatenate_videoclips(clips, method="compose")

but it's not working for me.

Pls suggest

Thanks

canbax
  • 3,432
  • 1
  • 27
  • 44
Asha Datla
  • 126
  • 1
  • 11
  • Instead of using "Imageclip" we used **clips.append(VideoFileClip(clip).set_duration(5))** we are getting first image but from second image it is getting garbled. i mean in the video is garbled from second image – Asha Datla Feb 06 '20 at 06:35

1 Answers1

1

I got it finally !

The issue was images i used, earlier the images were 3mb, 1mb etc but later i understood that all images should be above 14KB and below 100KB and possibly jpg files

clips = []
for file in os.listdir("E:\\images\\"):
    if file.endswith(".jpg"):
       clips.append(VideoFileClip("E:\\images\\"+ file).set_duration(10))

video = concatenate_videoclips( clips,method='compose')
audioclip = AudioFileClip("back.mp3",fps=44100) 

videoclip = video.set_audio(audioclip)
videoclip.write_videofile('ab23.mp4',codec='mpeg4', fps=24,audio=True)

Thanks everybody......

my technology stack

python: 3.8.1

moviepy:1.0.1

Asha Datla
  • 126
  • 1
  • 11