[英]convert all image into separate video using moviepy python
I have 10 images in a folder under current directory of where my python script is stored.我的 python 脚本所在的当前目录下的文件夹中有 10 张图像。 I want to convert all my 10 images into 10 videos with the same file name (or) existing filename+suffix(somename).mp4.
我想将我所有的 10 个图像转换为 10 个具有相同文件名(或)现有文件名+后缀(somename).mp4 的视频。 The problem is the below script is converting either all images into one video or erroring out.
问题是以下脚本正在将所有图像转换为一个视频或出错。 Need help to fix my problem.
需要帮助来解决我的问题。
Error: Traceback (most recent call last): File "1.py", line 17, in video.write_videofile(filename, prefix+".mp4", fps=24) TypeError: write_videofile() got multiple values for argument 'fps'错误:回溯(最近一次调用最后一次):文件“1.py”,第 17 行,在 video.write_videofile(文件名,前缀+“.mp4”,fps=24)类型错误:write_videofile()得到了参数“fps”的多个值
import os
from moviepy.editor import *
base_dir = os.path.realpath(".")
print(base_dir)
directory=sorted(os.listdir('.'))
print(directory)
clips = []
for filename in directory:
if filename.endswith(".jpg"):
prefix = filename.split(".jpg")[0]
clips.append(ImageClip(filename).set_duration(1))
print(clips)
video = concatenate(clips, method="compose")
video.write_videofile(filename, prefix+".mp4", fps=24)
The error is complaining that it is receiving to many arguments.该错误抱怨它正在接收许多 arguments。
Try running the write_videofile
without the filename argument.尝试在没有文件名参数的情况下运行
write_videofile
。 The signature only accepts one positional argument which should be the file you are writing to.签名只接受一个位置参数,它应该是您正在写入的文件。
video.write_videofile(prefix+".mp4", fps=24)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.