简体   繁体   English

如何使用moviepy连接多个视频

[英]How to concatenate multiple videos using moviepy

Yeah, basically we want to join multiple videos like this: 1 + 1 + ...= 11... (1:video) sorry that's the best example i could come up with on the spot.是的,基本上我们想加入多个这样的视频:1 + 1 + ...= 11 ... (1:video) 抱歉,这是我当场能想到的最好的例子。 and export them to be one video并将它们导出为一个视频

Refer this Example:参考这个例子:

from moviepy.editor import VideoFileClip, concatenate_videoclips

# Read files
vid1 = VideoFileClip("video1.mp4")
vid2 = VideoFileClip("video2.mp4")
vid3 = VideoFileClip("video3.mp4")

# Concat them
final = concatenate_videoclips([vid1, vid2, vid3])

# Write output to the file
final.write_videofile("newVideo.mp4")

Hope this helps you!希望这对你有帮助!

A had problems with the solution when tried to concatenate two .avi videos. A 在尝试连接两个 .avi 视频时遇到了解决方案问题。 I used the solution by 'night vision', to create not .avi, but mp4 instead, using mp4 codec我使用了“夜视”的解决方案,而不是创建 .avi,而是创建 mp4,使用 mp4 编解码器

def concatenate_videos(list_videos,newname):
    
    from moviepy.editor import VideoFileClip, concatenate_videoclips

    concatinated = concatenate_videoclips([VideoFileClip(v) for v in list_videos])

    concatinated.write_videofile(newname + '.mp4', codec='libx264')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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