Moviepy: No sound with an audio clip add to an video in quicktime

Created on 20 Jun 2018  路  4Comments  路  Source: Zulko/moviepy

This is my code

from moviepy.editor import *
import moviepy.video.fx.all as vfx
import os

def create(self):
        base_dir = os.path.realpath("./assets")
        img = [
          base_dir + '/2.jpg',
          base_dir + '/3.jpg',
          base_dir + '/4.jpg'
        ]

        audioclip = AudioFileClip(base_dir+'/demo.mp3')
        clips = [ImageClip(m).fx(vfx.resize, newsize=(520,300)).fx(vfx.scroll, h=280, w=480, x_speed=12).set_duration(2) for m in img]
        videoclip = concatenate_videoclips(clips, method="compose")
        finalclip = videoclip.set_audio(audioclip.set_duration(videoclip.duration))
        finalclip.write_videofile("demo.mp4", fps=25, codec="mpeg4", audio_codec='libmp3lame')

Expected Behavior

Has sound in the video

Actual Behavior

Has no sound in the quicktime player but has in vlc锛宎nd same issue with any audio_codec.

pls help!

Most helpful comment

I found the solution in other issue

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

All 4 comments

I found the solution in other issue

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

I found the solution in other issue

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

How do I know my temp_audiofile?

help me out
In Result Still no Sound, Cant Find Solution

Specifying an audio_codec while writing the file was sufficient to make it work for me, e.g.,

video.write_videofile(edit, audio_codec='aac')
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tburrows13 picture tburrows13  路  3Comments

bilel picture bilel  路  4Comments

bobozar picture bobozar  路  4Comments

skizzy picture skizzy  路  3Comments

Netherdrake picture Netherdrake  路  5Comments