globocom / globocom/m3u8

Parsing and dumping of multiple EXT-X-KEYs per segment is not supported

Open
#283 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.3k
Forks
496
PR merge metrics
No merged PRs in 30d

Description

The HLS spec is clear that a segment may be preceeded with multiple EXT-X-KEY tags, so long as they resolve to a single decryption key. This allows multiple DRMs to be supported using Common Encryption.

When the example playlist below is parsed, `segment[0]['key']` only lists the last key that preceeded the segment. Dumping the playlist object results in only the last key preceeding the segment appearing in the output. We need to be able to have a list of keys associated with a segments, possibly manipulate these, and dump them correctly.

Note: `m3u8['keys']` includes all keys, but it doesn't correctly associated keys with segments using `by_key`, presumably because of the above.

Usually I would knock something together, but key handling seems a bit confusing to me and am looking for a bit of direction about what might be the best way to approach this. I am tempted simply to add `segment['keys']` and always return a list (or None when no keys), but it's not obvious what `segment['key']` should be, or how `m3u8['keys']` would operate, in this model. Does anyone else have an opinion here?

```
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MAP:URI="0.m4s"
#EXT-X-PROGRAM-DATE-TIME:2022-07-04T11:30:11.680150Z
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://blah",IV=0xd7c3306f79c9b7d179f5dd09e2431d6e,KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="data:pssh...",IV=0xd7c3306f79c9b7d179f5dd09e2431d6e,KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",KEYFORMATVERSIONS="1"
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="data:pssh...",IV=0xd7c3306f79c9b7d179f5dd09e2431d6e,KEYFORMAT="com.microsoft.playready",KEYFORMATVERSIONS="1"
#EXTINF:6.006,
275879823.m4s
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the parser and dumper handle EXT-X-KEY tags, including segment[0]['key'], m3u8['keys'], and by_key, using the example playlist as a reproduction. Done means multiple keys remain associated with one segment, can be manipulated, are correctly indexed, and are emitted again when dumping.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.