小智 5
存在一个
temp_audiofile
Run Code Online (Sandbox Code Playgroud)
write_videofile 函数中的参数默认创建一个临时目录来存储视频的 mp3 文件。Moviepy 尝试在随机位置创建目录,该位置很可能没有非 root 用户的写入和执行权限,因此权限被拒绝投诉。简单地
chmod -R 777 <directory of your choice(preferably tmp)>
Run Code Online (Sandbox Code Playgroud)
在终端中,然后将该目录的绝对路径连同组成的文件名传递给 temp_audiofile 参数,如下所示
final_clips.write_videofile(abs_path, temp_audiofile=/tmp/random_name.mp3)
Run Code Online (Sandbox Code Playgroud)
这应该可以解决权限被拒绝的问题。