我正在尝试在 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)