0

I have just taken a simple video clip and made a rendered video of it using moviepy. This is my code :

import moviepy.editor as mpe 

video_clip = mpe.VideoFileClip("video.mp4")
audio_clip = mpe.AudioFileClip("closer.mp3")

video_clip.to_videofile("testingaudio.mp4",audio_codec = 'aac',audio = True)

The video is created. I even played it in VLC but there is no audio in it.

Józef Podlecki
  • 10,453
  • 5
  • 24
  • 50

1 Answers1

0

You need to add the audio clip to the video clip before writing it to a file.

Example:

import moviepy.editor as mpe 

video_clip = mpe.VideoFileClip("video.mp4")
audio_clip = mpe.AudioFileClip("closer.mp3")

video_clip = video_clip.set_audio(audio_clip)

video_clip.write_videofile("testingaudio.mp4", audio_codec='aac')
Tom Burrows
  • 2,225
  • 2
  • 29
  • 46