帮小姐姐合并视频写的程序

Muxxs
Muxxs 2018年02月09日
  • 在其它设备中阅读本文章

合并视频(目测只适合小视频,大的比较慢,装逼失败 - -)

#coding=utf-8

from  moviepy.editor  import  VideoFileClip , concatenate_videoclips
import os,uniout,time
start = time.time()
def cut(name):
    clip = []
    file = []
    for rt, dirs, files in os.walk("/Users/wangjiao/Desktop/news/"):
        for f in files:
            fname = os.path.splitext(f)
            if fname[1]==name:
                file.append("/Users/wangjiao/Desktop/news/"+f)
    file.sort()
    print file
    for i in file:
        clip.append(VideoFileClip(i))
    if not clip==[]:
        final_clip  =  concatenate_videoclips(clip)
        final_clip.write_videofile("final.mp4")
name=str(raw_input("请输入文件后缀:")).replace("\n","").replace(" ","")
if name.find(".")==-1:
    name="."+name
cut(name)
end = time.time()
print "use:"+str(end-start)+"s"

其实自己小视频用是可以的同时安利 moviepy 这个库