-
Notifications
You must be signed in to change notification settings - Fork 6
/
marge.py
50 lines (41 loc) · 1.4 KB
/
marge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import logging
import colorlog
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
console_handle = logging.StreamHandler()
console_handle.setLevel(logging.DEBUG)
file_handle = logging.FileHandler('run.log')
file_handle.setLevel(logging.DEBUG)
formatter = colorlog.ColoredFormatter(
"%(log_color)s%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s",
datefmt=None,
reset=True,
log_colors={
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red,bg_white',
},
secondary_log_colors={},
style='%'
)
console_handle.setFormatter(formatter)
file_handle.setFormatter(formatter)
logger.addHandler(console_handle)
logger.addHandler(file_handle)
if __name__ == "__main__":
current_path =os.getcwd()
logger.info("当前文件目录:" + current_path)
fp = open("ffmpeg_filelist.txt","w")
for root,dirs,files in os.walk(current_path):
for file in files:
if file.endswith(".ts") and file.startswith("5xtv_"):
fp.write("file \'%s\'\n" % (root + os.sep + file))
fp.close()
logger.info("生成需要合并的分片目录")
logger.critical("开始合并视频分片")
shell = "ffmpeg.exe -f concat -safe 0 -i ffmpeg_filelist.txt -vcodec copy -acodec copy 5xtv.mp4"
os.system(shell)
logger.info("合并结束")