简体   繁体   中英

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. but the issue is I cant concatenate them using moviepy while they are in a list. 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

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM