Skip to content

Commit fdbc4b2

Browse files
authored
Add files via upload
1 parent 5b044ee commit fdbc4b2

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

blog29-MoviePy/test06.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- coding: utf-8 -*-
2+
import os
3+
from moviepy.editor import *
4+
5+
#递归获取文件名称
6+
def file_name(file_dir):
7+
L=[]
8+
for root, dirs, files in os.walk(file_dir):
9+
for file in files:
10+
if os.path.splitext(file)[1] == '.mp4':
11+
L.append(os.path.join(root, file))
12+
return L
13+
14+
#主函数
15+
if __name__ == '__main__':
16+
filePath = 'vedio'
17+
file_list = file_name(filePath)
18+
19+
k = 1
20+
L = []
21+
for name in file_list:
22+
print(name)
23+
#获取视频总时间
24+
video = VideoFileClip(name)
25+
times = video.duration
26+
L.append(video)
27+
print(times)
28+
29+
#视频合成 帧数大致就是24
30+
final_clip = concatenate_videoclips(L)
31+
final_clip.to_videofile('./final.mp4', fps= 24, remove_temp=True)
32+

0 commit comments

Comments
 (0)