Maxim
Maxim

Reputation: 41

No audio when writing video using write_videofile

I am trying to concat a couple of video clips to generate a long video. Each of short videos has audio, but when I am writing the concatenated video, it does not have audio. Below is the code that I am using. Any suggestion?

from moviepy.editor import VideoFileClip, concatenate_videoclips
final_clip = VideoFileClip('Clips/' + videofiles[0], audio=True)
for i in range(1, len(videofiles)):
    next_clip = VideoFileClip('Clips/' + videofiles[i], audio=True)
    final_clip = concatenate_videoclips([final_clip, next_clip])
final_clip.write_videofile("Clips/final_clip.mp4")

Upvotes: 2

Views: 706

Answers (1)

Maxim
Maxim

Reputation: 41

Specifying the codec of audio (audio_codec="aac") while writing the video using write_videofile fixed the issue.

Upvotes: 2

Related Questions