python merge video

 

Video merge

Input: Contains video folder (note the path: such as D: \\ moves \\ joy double slash), the name of the combined content such as (I merge video do not add .mp4)

The output is: my video .mp4 + a merge audio files

from moviepy.editor import *
import os

# 定义一个数组


def getFileList(path):
    L=[]
    listmv=os.listdir(path)
    print(listmv)
    for each in listmv:
        if os.path.isfile(path+'\\'+each) :
            if each.endswith('.mp4') or each.endswith('.MP4'):
                #Print (int (each.strip ( '. MP4'))) 
# watch my video folder is a digital + .mp4! If this is not naming format to modify the code below! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
L.append (int (each.split ( '.' ) [0] ) ) L.sort () # videofileclip Loading video mvFiles = [VideoFileClip (path + ' \\ ' + STR (E) + ' .mp4 ' ) for E in L] return mvFiles DEF main (the inpath, outMvNmae): mvTemp = getFileList (the inpath) final_clip = concatenate_videoclips (mvTemp) final_clip.to_videofile (outMvNmae + '.mp4', fps=24, remove_temp=False) path='F:\\temp' name='combine' main(path,name)

Input:

 

 

 

Output:

 

 

 

Reference: https://www.jianshu.com/p/98a0c091c4bf

 

Guess you like

Origin www.cnblogs.com/51python/p/11470460.html