Home > Back-end >  Video generated from a picture and one auido file has no sound using moviepy
Video generated from a picture and one auido file has no sound using moviepy

Time:12-27

I am trying to make a video with one image and one auido file using the following code:

from moviepy.editor import *

audio = AudioFileClip("/users/qingzhou/downloads/Taylor.wav")
image = ImageClip("/users/qingzhou/downloads/shuangyu.png").set_duration(audio.duration)
clip = image.set_audio(audio)

clip.write_videofile("/users/qingzhou/downloads/rock.mp4",fps=30)

After running it, I got the following notifications:

/Users/qingzhou/venv/Python3.9new/bin/python /Users/qingzhou/IdeaProjects/programFlow/Factory.py
Moviepy - Building video /users/qingzhou/downloads/rock.mp4.
MoviePy - Writing audio in rockTEMP_MPY_wvf_snd.mp3
t:   0%|          | 0/1972 [00:00<?, ?it/s, now=None]MoviePy - Done.
Moviepy - Writing video /users/qingzhou/downloads/rock.mp4

Moviepy - Done !
Moviepy - video ready /users/qingzhou/downloads/rock.mp4

Process finished with exit code 0

The video generated has no sound at all after trying using different forms of auido file (.mp3 and .wav).

I cannot find any useful information online to address it.

I hope to resolve this issue because I am building a video processing bot to make a large number of videos with the same foramt using different content.

CodePudding user response:

The code is working properly. Please pay attention to the audio file.

  • Related