0

So I have 7 .mp3 audio files concatenated together

audioFiles = [a for a in glob.glob(audioPath + "**/*.mp3", recursive=True)]
audios = []
for audio in audioFiles:
    audios.append(AudioFileClip(audio))

audioClip = concatenate_audioclips([audio for audio in audios])

and 14 .mp4 files concatenated together

files = [f for f in glob.glob(path + "**/*.mp4", recursive=True)]
clips = []
for file in files:
    clips.append(VideoFileClip(file))
finalClip = concatenate_videoclips([clip for clip in clips])

Rendering the video looks:

finalClip.audio = audioClip
finalClip.write_videofile("my_concatenation.mp4")

But these video files concatenated together takes only 10 minutes to watch.

The program extends the video clip with 20 minutes. So the video is 30 minute with the audio + video and the video takes 10 minutes so from then minutes the last frame is showing for the last 20 minutes.

How can I tell the program not to stretch the video?

Marci
  • 129
  • 1
  • 13

1 Answers1

3

@McSinyx moviepy is basically a wrapper around ffmpeg, stop giving people advice to use other software instead of actually answering the question. (Writing here because new account and can't comment until 50rep)

The answer to your question is that you want to use "CompositeVideoClip" instead of "concatenate_videoclips". Concatenate adds them one by one, so clip 1 will play, then clip2 etc. Composite on the other hand will place them on the same "track" so they will all be played at the same time. To split them up you need to add durations & start_times. Think of it as a normal video editing software where you have different tracks and you can add video and audio on two different tracks played at the same time. Example below

video = CompositeVideoClip([clip1,clip2,audio1]

Read more about this on the following link and don't forget to choose answer if this helped you :) https://zulko.github.io/moviepy/getting_started/compositing.html

Xetra
  • 31
  • 2