tor*_*t32 2 python concatenation m3u8
我正在尝试串联python中.m3u8播放列表中的.ts文件,
有什么办法吗?如果是,请说明如何
提前致谢
这应该可行,我只向这个简短的脚本添加了两个注释,因为我猜这几乎是不言而喻的。
import shutil
# Parse playlist for filenames with ending .ts and put them into the list ts_filenames
with open('playlist.m3u8', 'r') as playlist:
ts_filenames = [line.rstrip() for line in playlist
if line.rstrip().endswith('.ts')]
# open one ts_file from the list after another and append them to merged.ts
with open('merged.ts', 'wb') as merged:
for ts_file in ts_filenames:
with open(ts_file, 'rb') as mergefile:
shutil.copyfileobj(mergefile, merged)
Run Code Online (Sandbox Code Playgroud)