python解析m3u8衔接_m3u8:Python m3u8 HTTP流媒体直播(HLS)传输的解析器

本文介绍了如何使用Python的m3u8库解析和处理m3u8播放列表,包括加载、转储播放列表,处理加密段,遍历不同比特率的变体播放列表,以及自定义标签和HTTP客户端等高级特性。
摘要由CSDN通过智能技术生成

m3u8

Python m3u8 parser.

Documentation

Loading a playlist

To load a playlist into an object from uri, file path or directly from string, use the load/loads functions:

import m3u8

playlist = m3u8.load('http://videoserver.com/playlist.m3u8') # this could also be an absolute filename

print(playlist.segments)

print(playlist.target_duration)

# if you already have the content as string, use

playlist = m3u8.loads('#EXTM3U8 ... etc ... ')

Dumping a playlist

To dump a playlist from an object to the console or a file, use the dump/dumps functions:

import m3u8

playlist = m3u8.load('http://videoserver.com/playlist.m3u8')

print(playlist.dumps())

# if you want to write a file from its content

playlist.dump('playlist.m3u8')

Supported tags

Encryption keys

The segments may be or not encrypted. The keys attribute list will be a list with all the different keys as described with #EXT-X-KEY:

Each key has the next properties:

method: ex.: "AES-128"

iv: the initialization vector, if available. Otherwise None.

If no #EXT-X-KEY is found, the keys list will have a unique element None. Multiple keys are supported.

If unencrypted and encrypted segments are mixed in the M3U8 file, then the l

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值