1
| pip install requests m3u8 pycryptodome -i https://mirrors.aliyun.com/pypi/simple/
|
多线程
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
| import os
import subprocess
outPath = 'F:/资料文档/zztt/' nameLength = len('f1bded9f280d7945fa5a1503a2669a66')
def merge_m3u8(m3u8Path): tsList = os.listdir(m3u8Path) if len(tsList) == 0: return mainName = tsList[0][0:nameLength] cmd = ' '.join(f"file '{m3u8Path + '/' + mainName}{i}.ts'" for i in range(0, len(tsList))) cmd = ''.join(f"{m3u8Path + '/' + mainName}{i}.ts\n" for i in range(0, len(tsList))) with open(f"input.txt", "w", encoding='utf-8') as f: f.write(cmd) outFileName = os.path.basename(m3u8Path)
output_filename = m3u8Path + "/" + outFileName + '.mp4'
result = subprocess.call(f"ffmpeg -f concat -safe 0 -i input.txt -c copy {output_filename}.mp4", shell=True) output = result.stdout.decode('utf-8')
if __name__ == '__main__': merge_m3u8('F:/资料文档/zztt/《独家猛料》')
|
下载 ffmpeg
本文地址: https://github.com/maxzhao-it/blog/post/7b6a6783/