Moviepy: no audio in written videofile when running on heroku

本秂侑毒 提交于 2020-01-24 01:10:18

问题


I am making videos with moviepy. Created locally, the final videofile has audio. When I run the same code on heroku, the final video has no audio.

First, I thought not using the /tmp directory on heroku might be the issue. I also followed advice to add audio parameters to write_videofile. Both didn't solve the problem.

I am using the heroku ffmpeg buildpack.

#Make soundtrack
soundtrack = AudioFileClip('https://storage.googleapis.com/ABC/music.mp3')
soundtrack = soundtrack.set_duration(final_clip.duration)

#Add soundtrack
final_clip = final_clip.set_audio(soundtrack)

#Write videofile
final_clip.write_videofile('tmp/video/combined_movie.mp4',
                           codec='libx264',
                           audio_codec='aac',
                           temp_audiofile='tmp/video/soundtrack-temp-audio.m4a',
                           remove_temp=False,
                           fps=10)

#Storing on google cloud
    try:
        upload_blob('ABC','tmp/video/combined_movie.mp4','tmp/video/combined_movie.mp4')

    except:
        print('error when uploading final video file to google storage.')

In the console is see:

Moviepy - Building video tmp/video/combined_movie.mp4.
MoviePy - Writing audio in %s
MoviePy - Done.                                                                                              
Moviepy - Writing video tmp/video/combined_movie.mp4
Moviepy - Done !                                                                                             
Moviepy - video ready tmp/video/combined_movie.mp4
Google Cloud Storage upload successful.

Help is appreciated!


回答1:


Finally found the solution!

I simply forked the same buildpack and changed the DOWNLOAD variable to ffmpeg version 4.1.3 (same version installed on my localhost). Just run this command on your terminal:

heroku buildpacks:add https://github.com/merwane/heroku-buildpack-ffmpeg-latest.git


来源:https://stackoverflow.com/questions/54979858/moviepy-no-audio-in-written-videofile-when-running-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!