简体   繁体   English

MoviePy ImageClip 随机生成灰色视频

[英]MoviePy ImageClip randomly producing grey videos

I am trying to create a simple video of one image with audio with MoviePy.我正在尝试使用 MoviePy 创建一个带有音频的图像的简单视频。 Working with the same code, sometimes MoviePy randomly produces greyed out and glitched videos like this:使用相同的代码,有时 MoviePy 会随机生成如下所示的灰色和故障视频: 视频变灰 (opened with VLC Media Player) (用 VLC 媒体播放器打开)

The audio works fine in the final video, and the image used is also completely fine.最终视频中的音频效果很好,使用的图像也完全没问题。 I tried searching but couldn't find anything that worked.我尝试搜索但找不到任何有用的东西。 I also re-downloaded FFMPEG , thinking it would solve the problem, but to no advantage.我也重新下载FFMPEG ,以为可以解决问题,但没有任何好处。

The code I am using is:我使用的代码是:

# assume aud_path, vid_path and out_path are set and imports have been done
aud_clip = AudioFileClip(aud_path)
vid_clip = ImageClip(vid_path)
vid_clip = vid_clip.set_audio(aud_clip).set_duration(aud_clip.duration)
vid_clip.write_videofile(out_path, temp_audiofile='temp-audio.m4a', remove_temp=True, codec="libx264", audio_codec="aac", fps=24)

Any help will be appreciated.任何帮助将不胜感激。

I figured it out, For anyone having a similar problem, the problem was in the vid_clip.write_videfile() method in the codec argument.我想通了,对于遇到类似问题的任何人,问题出在codec参数中的vid_clip.write_videfile()方法中。

I changed the codec to "mpeg4" and it is working fine now.我将codec更改为"mpeg4" ,现在工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM