No audio when adding Mp3 to VideoFileClip MoviePy

moviepy remove audio
moviepy concatenate audio
add audio to video python
moviepy preview
moviepy imageclip example
moviepy alpha channel
compositeaudioclip moviepy
moviepy convert mov to mp4

I'm trying to add an mp3 audio file to a video clip that I'm creating out of images with MoviePy. When the script runs it creates the mp4 file and plays successfully, however there's no audio. I'm not really sure why and can't seem to find a ton of documentation around this in general. MoviePy is pretty new to me so any help would be appreciated - thank-you!

def make_video(images):
    image_clips = []
    for img in images:
        if not os.path.exists(img):
            raise FileNotFoundError(img)
        ic = ImageClip(img).set_duration(3)
        image_clips.append(ic)

    video = concatenate(image_clips, method="compose")
    video.set_audio(AudioFileClip("audio.mp3")) 
    video.write_videofile("mp4_with_audio.mp4", fps=60, codec="mpeg4")

Admittedly, this question is old but comes high in search results for the problem. I had the same issue and think the solution can be clarified.

The line:

video.set_audio(AudioFileClip("audio.mp3")) 

actually does not change the audio track of the "video" object, but returns a copy of the object with the new AudioFileClip attached to it.

That means that the method:

video.write_videofile("mp4_with_audio.mp4", fps=60, codec="mpeg4")

does not write the final file with the new audio track, since the "video" object remains unchanged.

Changing the script as per the below solved the issue for me.

video_with_new_audio = video.set_audio(AudioFileClip("audio.mp3")) 
video_with_new_audio.write_videofile("mp4_with_audio.mp4", fps=60, codec="mpeg4")

See also the docs

No audio when adding Mp3 to VideoFileClip MoviePy · Issue #350 , I'm trying to add an mp3 audio file to a video clip that I'm creating out of images with MoviePy. When the script runs it creates the mp4 file and  When check the file sizes, and the logs, it does show that its writing the audio to an mp3 and this temporary mp3 has the music. Also the filesize indicates that the audio was added to the file. But when you play the video, you simply can't here anything and also when looking at the file properties, the doesn't show that it has audio channels.

Check the video mp4_with_audio.mp4 with VLC media player, i also have same issue with quick player.

CompositeVideoClip has no audio · Issue #876 · Zulko/moviepy , Actual Behavior. The video file generated at end of the process has no audio. VideoFileClip(video_filename) logo = (mp.ImageClip("logo.png") Sv3n added a commit to Sv3n/moviepy that referenced this issue on Feb 25, 2019. @Sv3n music = "D:/instavideo/comdyeditmusic/Part1 .mp3" clip = mp. Strange, at first sight it looks like the fps of your mp3 is given as 90k while moviepy would expect 90000. I thought this was taken care of. Could you try converting your mp3 to something else ? Like open a terminal and type ffmpeg -i 1.mp3 -r 48000 1bis.mp3 to convert the mp3 to a 48000fps file ?

This worked for me:

clip.write_videofile(out_path, 
                     codec='libx264', 
                     audio_codec='aac', 
                     temp_audiofile='temp-audio.m4a', 
                     remove_temp=True
                     )

Found it here: https://github.com/Zulko/moviepy/issues/51

No Sound : moviepy, So I'm working with a very simple project, and I'm getting no sound. import * clip = VideoFileClip("demoVideowithSound.mp4").subclip(1,2) audio I see that it's set aside a temp .mp3 that, of course, disappears when its done using it. Sv3n added a commit to Sv3n/moviepy that referenced this issue Feb 25, 2019. The old order binds the `-an` flag to the next stream, which is the audio file (which is subsequently ignored).

I run into this problem too. I found a solution, try

video = video.set_audio(AudioFileClip("audio.mp3"))

Audio in MoviePy, Note that when you cut, mix or concatenate video clips in MoviePy the audio is from moviepy.editor import * audioclip = AudioFileClip("some_audiofile.mp3") videoclip = VideoFileClip("some_video.avi") audioclip = videoclip.audio  So, create a CompositeAudioClip with the audio of the video clip and the new audio clip, then set the old videoclip's audio to the composite audio track. Full working code: from moviepy.editor import * videoclip = VideoFileClip("filename.mp4") audioclip = AudioFileClip("audioname.mp3") new_audioclip = CompositeAudioClip([videoclip.audio

AudioClip, class moviepy.audio. The frame does not mean much for a sound, it is just a float. from moviepy.editor import VideoFileClip >>> myclip snd.close() >>> snd = AudioFileClip("song.mp3", fps = 44100) >>> second_reader = snd.​coreader() >  There's no audio track whatsoever on the output. If I open an info window in the player, I only have a video track. I've tried a few different types of files (thinking maybe it had to do with audio compression types), but no luck. from moviepy.editor import * clip = VideoFileClip("demoVideowithSound.mp4").subclip(1,2) clip.write_videofile

moviepy.editor.VideoFileClip Python Example, This page provides Python code examples for moviepy.editor. VideoFileClip('​video.mp4') clip.audio.write_audiofile(f'{safe_filename(video.title)}.mp3') await  I am trying to convert a numpy array of an audio file sampled at 44100 Hz into an AudioFileClip in MoviePy so I can overdub a videoFileClip. The online documentation is unclear on this topic. Any

Developers, No audio when adding Mp3 to VideoFileClip MoviePy. Javascript Required. Kindly enable Javascript. Main. About. FAQ · Fees · Press · Teams · SALT. Get CAN Hi, currently I'm working on a hobby project. I extracted small clips from a video and then concatenate them to create a new video file. Can we remove the audio from the original video file and add/merge any new audio/song file ?

Comments
  • I'm not sure how this is any different then what I posed in my question. I think the answer might be that both files need to be the same length. That's what worked for me anyway, not what you're suggesting above.
  • VLC Player plays it without audio as well.
  • I've tried this before and I just did again as a sanity check. Same issue, no audio. I'm starting to think that adding audio like this is not as straightforward as the moviepy doc claims. I'm guessing the file might need to be formatted to a wav or something, codecs have to be changed, time has to be exactly the same etc..all of those differences with the generated video I have is probably prevently the audio from being set correctly. I'm really new to A/V tech like this; it's really uncharted territory for me. Was hoping this would be a simple script.
  • And I just started coding in Python one month ago... :)
  • This is working code. It's a bit untidy and not well structured but this is how I got moviepy to work. Have a look in line 51 and 93. github.com/JSchwehn/FeedToYoutube/blob/master/videoCreator.py
  • I actually got it to work after looking at your code. I'm not really sure what it was, but once I started chopping the audio file to match the length of the video everything started to work correctly. Thanks for your help!