我有一个文件夹的视频,我想快进使用多个线程使用moviePy。如何动态地从文件夹中获取视频,而不是静态地给出它们的路径?这是我的代码:
导入操作系统
从nat排序导入
从线程导入线程
def fast(path,thread_name):
如果os.path.splitext(path)1 == '.mp4':#print(path(Path)) clip = (VideoFileClip(path).fx(vfx.speedx,5)) #print(Path) clip.to_videofile('G:/Ocsid Technologies/Video_1/‘+线程_name+ '.mp4',codec=’libx264 264‘)
't1')).start() =线程(target=fast,args=("G:/Ocsid Technologies/Video_1/sample1.mp4“)
t2 =线程(target=fast,args=(“G://Video_1/sample2.mp4”,‘t2’).start()
t3 =线程(target=fast,args=(“G://Video_1/sample3.mp4”,'t3‘).start()
t4 =线程(target=fast,args=(“G://Video_1/sample4.mp4”,'t4‘).start()
发布于 2022-03-07 17:36:51
您可以使用glob.glob()
枚举文件,并使用enumerate
获取线程名称的计数器。
import glob
# ...
for i, filename in enumerate(glob.glob("G:/Ocsid Technologies/Video_1/*.mp4"), 1):
thread_name = f"t{i}"
Thread(target=fast, args=(filename, thread_name)).start()
https://stackoverflow.com/questions/71385029
复制相似问题