python合并大量ts文件成mp4格式(ps:上限是450,亲测)

import os
#exec_str = r'copy /b  ts/c9645620628078.ts+ts/c9645620628079.ts  ts/1.ts'
#os.system(exec_str)
f = open('index.m3u8', 'r', encoding='utf-8')
text_list = f.readlines()
files = []
for i in text_list:
    if i.find('#EX')==-1:
        files.append(i)

f.close()


tmp = []
for file in files[0:450]:
    tmp.append(file.replace("\n",""))
    # 合并ts文件
os.chdir("ts/")
shell_str = '+'.join(tmp)
#print(shell_str)
shell_str = 'copy /b '+ shell_str + ' 5.mp4'

os.system(shell_str)
print(shell_str)

 

 

关注公众号:Python爬虫数据分析挖掘,学习更多python知识

posted @ 2020-09-01 22:12  Python研究者  阅读(569)  评论(0编辑  收藏  举报