python合並大量ts文件成mp4格式(ps:上限是450,親測)


 1 import os
 2 #exec_str = r'copy /b  ts/c9645620628078.ts+ts/c9645620628079.ts  ts/1.ts'
 3 #os.system(exec_str) 
 4 f = open('index.m3u8', 'r', encoding='utf-8')
 5 text_list = f.readlines()
 6 files = []
 7 for i in text_list:
 8     if i.find('#EX')==-1:
 9         files.append(i)
10         
11 f.close()
12 
13 
14 tmp = []
15 for file in files[0:450]:
16     tmp.append(file.replace("\n",""))
17     # 合並ts文件
18 os.chdir("ts/")
19 shell_str = '+'.join(tmp)
20 #print(shell_str)
21 shell_str = 'copy /b '+ shell_str + ' 5.mp4'
22 
23 os.system(shell_str)
24 print(shell_str)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM