Closed HFrost0 closed 1 year ago
Here is a way to fall back to the Media Sequence if the Initialization Vector is missing:
import m3u8
playlist_text = '...' # Your text here
parsed_playlist = m3u8.loads(playlist_text)
seq_no = parsed_playlist.media_sequence or 0
for n, segment in enumerate(parsed_playlist.segments, seq_no):
iv = segment.key.iv or f'0x{n:032x}'
# do whatever you need to do with the IV
Reference: RFC 8216, Section 5.2
An EXT-X-KEY tag with a KEYFORMAT of "identity" that does not have an
IV attribute indicates that the Media Sequence Number is to be used
as the IV when decrypting a Media Segment, by putting its big-endian
binary representation into a 16-octet (128-bit) buffer and padding
(on the left) with zeros.
as always thank you @bbayles
@bbayles @leandromoreira Thanks for your solution👍, is there any plan to put this inside the m3u8
lib instead of letting user do it by themself?
I opened https://github.com/globocom/m3u8/pull/310, which would make things a bit simpler.
Thank you @bbayles
When we need AES to decrypt segment, IV is important. In some m3u8 file, iv is not provided while can be generated by a specific rule which I found in decrypt-m3u8-playlist-encrypted-with-aes-128-without-iv
Can we do this process in m3u8 lib instead of leave the seg.key.iv to None (I found this behavior in version 3.2.0)?