音频导出失败,可能是因为您指定的比特率大于两倍或对于视频编解码器而言太低
The audio export failed, possily because the bitrate you specified was > two high or too low for the video codec
尝试使用 write_videofile
和 moviepy 库将 m4a (aac) 音频文件写入视频时,我偶尔会收到以下错误。我无法确定导致此错误的确切原因,因为它很少发生。我试过指定不同的音频比特率,但它仍然引发异常。
video = video.set_audio(AudioFileClip("asdf.m4a"))
video.write_videofile("video.mp4", fps=FPS, codec='libx264', audio_codec="aac", temp_audiofile='temp-audio.m4a', remove_temp=True, audio_bitrate="256k")
[Errno 32] Broken pipe MoviePy error: FFMPEG encountered the
following error while writing file temp-audio.m4a:
temp-audio.m4a: Permission denied
The audio export failed, possily because the bitrate you specified was
two high or too low for the video codec.: IOError Traceback (most
recent call last):
video.write_videofile("video.mp4",
fps=FPS, codec='libx264', audio_codec="aac",
temp_audiofile='temp-audio.m4a', remove_temp=True,
audio_bitrate="256k")
File "", line 2, in write_videofile File
"/var/task/moviepy/decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "", line 2, in write_videofile File
"/var/task/moviepy/decorators.py", line 137, in
use_clip_fps_by_default return f(clip, *new_a, **new_kw) File
"", line 2, in write_videofile File
"/var/task/moviepy/decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "/var/task/moviepy/video/VideoClip.py", line 331, in
write_videofile verbose=verbose) File "", line 2,
in write_audiofile File "/var/task/moviepy/decorators.py", line 54,
in requires_duration return f(clip, *a, **k) File
"/var/task/moviepy/audio/AudioClip.py", line 204, in write_audiofile
verbose=verbose, ffmpeg_params=ffmpeg_params) File
"", line 2, in ffmpeg_audiowrite File
"/var/task/moviepy/decorators.py", line 54, in requires_duration
return f(clip, *a, **k) File
"/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 162, in
ffmpeg_audiowrite writer.write_frames(chunk) File
"/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 122, in
write_frames raise IOError(error)
IOError: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the
following error while writing file temp-audio.m4a: temp-audio.m4a:
Permission denied The audio export failed, possily because the
bitrate you specified was two high or too low for the video codec.
问题是我在 AWS Lambda 实例上 运行 这个脚本。如 AWS Lambda 文档所述,我的所有文件都应该写入 /tmp
。一旦我所有的临时文件都写入指定目录; FFMpeg 不再引发异常。
举个例子,这看起来像:
vid_path = "/tmp/outputvideofile.mp4"
audio_path = "/tmp/myaudiofile.mp3"
finalclip.write_videofile(vid_path,fps=15, temp_audiofile=audio_path, remove_temp=True)
尝试使用 write_videofile
和 moviepy 库将 m4a (aac) 音频文件写入视频时,我偶尔会收到以下错误。我无法确定导致此错误的确切原因,因为它很少发生。我试过指定不同的音频比特率,但它仍然引发异常。
video = video.set_audio(AudioFileClip("asdf.m4a"))
video.write_videofile("video.mp4", fps=FPS, codec='libx264', audio_codec="aac", temp_audiofile='temp-audio.m4a', remove_temp=True, audio_bitrate="256k")
[Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file temp-audio.m4a:
temp-audio.m4a: Permission denied
The audio export failed, possily because the bitrate you specified was two high or too low for the video codec.: IOError Traceback (most recent call last):
video.write_videofile("video.mp4", fps=FPS, codec='libx264', audio_codec="aac", temp_audiofile='temp-audio.m4a', remove_temp=True, audio_bitrate="256k")
File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k)
File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 137, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k)
File "/var/task/moviepy/video/VideoClip.py", line 331, in write_videofile verbose=verbose) File "", line 2, in write_audiofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/AudioClip.py", line 204, in write_audiofile verbose=verbose, ffmpeg_params=ffmpeg_params) File "", line 2, in ffmpeg_audiowrite File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 162, in ffmpeg_audiowrite writer.write_frames(chunk) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 122, in write_frames raise IOError(error)
IOError: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file temp-audio.m4a: temp-audio.m4a: Permission denied The audio export failed, possily because the bitrate you specified was two high or too low for the video codec.
问题是我在 AWS Lambda 实例上 运行 这个脚本。如 AWS Lambda 文档所述,我的所有文件都应该写入 /tmp
。一旦我所有的临时文件都写入指定目录; FFMpeg 不再引发异常。
举个例子,这看起来像:
vid_path = "/tmp/outputvideofile.mp4"
audio_path = "/tmp/myaudiofile.mp3"
finalclip.write_videofile(vid_path,fps=15, temp_audiofile=audio_path, remove_temp=True)