0

I had a folder with 2 ".mp3" files which takes and image from separate folder and renders it to an .mp4 video. Problem - If the duration of actual audio is 4 mins, I get the .mp4 file of duration 4 mins but the audio completes at 2.10 seconds and rest of video stays with no audio. Not sure where I am going wrong here.

Code:

from moviepy.editor import *
from pathlib import Path

music_folder = Path(r'C:\Users\PycharmProjects\Audio')
Image = ImageClip(r'C:\Users\PycharmProjects\Image\image.jpg')

for i in music_folder.glob("*.mp3"):
    audio_clip = AudioFileClip(str(i))

    image = Image.set_duration(audio_clip.duration)
    audio = image.set_audio(audio_clip)

    audio.write_videofile(str(i)+'.mp4', fps=4)

0 Answers0