How to set audio clip on image clip in moviepy?

Viewed 619

I'm trying to set audio clip on image clip in moviepy. I read this page, then I wrote code like this.

from moviepy.editor import *
clip = ImageClip('img/output_1.png')
audio_clip = AudioFileClip('audio/output_1.mp3')
clip = clip.set_duration(audio_clip.duration)
clip = clip.set_audio(audio_clip)

Audio and duration are returns value.

>>> clip.audio
<moviepy.audio.io.AudioFileClip.AudioFileClip object at 0x1241dbd30>
>>> clip.duration
4.18

However when I write as file.

clip.write_videofile('mov/sample.mp4',fps=4)

I can't hear the sound. Are there any mistake on my code? I don't know how should I change my code... If you have any idea please help me!

My environment is

MacOS 11.3.1
python 3.9.5
moviepy 1.0.3

I had run same code on google colab, I got same problem. The video has 4.18 seconds, however it's no sound...

I downloaded audio file from ondoku3 and youtube as mp3

1 Answers

I found QuickTime can't play sound. When I play VLC, I can hear the sound.

And also when I merge audio and video with ffmpeg. I got same problem. So I think this problem from ffmpge convert problem or QuickTime problem.

Related