admin 管理员组

文章数量: 1086864

MoviePy error: FFMPEG encountered the following error while writing file

安装moviepy后,在执行write_videofile函数将输入写入视频文件时,出现错误:

MoviePy error: FFMPEG encountered the following error while writing file new_videoTEMP_MPY_wvf_snd.mp3:b"Unknown encoder 'libmp3lame'\r\n"The audio export failed because FFMPEG didn't find the specified codec for audio encoding (libmp3lame). Please install this codec or change the codec when calling to_videofile or to_audiofile. For instance for mp3:>>> to_videofile('myvid.mp4', audio_codec='libmp3lame')

原因是使用了conda install -c conda-forge moviepy,改为使用pip install moviepy即可。

conda安装测试过程

> conda create -n condatest python=3.7
> conda activate condatest
> conda install -c conda-forge moviepy
> python
>>> from moviepy.editor import *
>>> v = VideoFileClip("video_example.mp4")
>>> v.write_videofile("new_video.mp4")
MoviePy error: FFMPEG encountered the following error while writing file new_videoTEMP_MPY_wvf_snd.mp3:b"Unknown encoder 'libmp3lame'\r\n"The audio export failed because FFMPEG didn't find the specified codec for audio encoding (libmp3lame). Please install this codec or change the codec when calling to_videofile or to_audiofile. For instance for mp3:>>> to_videofile('myvid.mp4', audio_codec='libmp3lame')>>> v.close()   
>>> exit()

pip安装测试过程

> conda create -n piptest python=3.7
> conda activate piptest
> pip install moviepy
> python
>>> from moviepy.editor import *
>>> v = VideoFileClip("video_example.mp4")
>>> v.write_videofile("new_video.mp4")
Moviepy - Building video new_video.mp4.
MoviePy - Writing audio in new_videoTEMP_MPY_wvf_snd.mp3
MoviePy - Done.
Moviepy - Writing video new_video.mp4Moviepy - Done !
Moviepy - video ready new_video.mp4>>> v.close() 
>>> exit()

本文标签: MoviePy error FFMPEG encountered the following error while writing file