[英]how to concatenate video files in moviepy when all video file paths are written in a list
im writing a code which takes inputs from user to get paths of video files the user want to concatenate.我正在编写一个代码,该代码从用户那里获取输入以获取用户想要连接的视频文件的路径。 now if the user has 5 videos which they want to concatenate and make one file out of them, my program does a good job getting all the videofile paths and stores them in a list.现在,如果用户有 5 个视频,他们想要连接起来并从中创建一个文件,我的程序可以很好地获取所有视频文件路径并将它们存储在列表中。 but the issue is I cant concatenate them using moviepy while they are in a list.但问题是当它们在列表中时我无法使用 moviepy 将它们连接起来。 this is the code这是代码
from moviepy.editor import VideoFileClip, concatenate_videoclips
listofpath=[]
no_vid = int(input('enter no of vid u wanna compile: '))
for i in range(no_vid):
vidpath = input('enter path to the files u wanna compile: ')
listofpath.append(vidpath)
print(listofpath)
final_clip = concatenate_videoclips([listofpath])
final_clip.write_videofile("E:\python_work\downloaded\my_concatenation.mp4")
from moviepy.editor import VideoFileClip, concatenate_videoclips
listofpath=[]
no_vid = int(input('enter no of vid u wanna compile: '))
for i in range(no_vid):
vidpath = input('enter path to the files u wanna compile: ')
listofpath.append(vidpath)
print(listofpath)
Create a list of VideoFileClip objects创建 VideoFileClip 对象的列表
clips = [VideoFileClip(file) for file in listofpath]
Concatenate the clips连接剪辑
final_clip = concatenate_videoclips(clips)
Then write the video然后写视频
final_clip.write_videofile("E:\python_work\downloaded\my_concatenation.mp4")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.