HLS I-frame only tracks detection
- Dominant language
- Java
- Stars
- 21.9k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hi all,
I have found that #EXT-X-I-FRAME-STREAM-INF variants are not presented in track groups if CODECS and RESOLUTION attributes are missed.
Here is an example of master playlist:
```
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=3200000,PROGRAM-ID=1,RESOLUTION=1920x1080
https://a787201989-zabava-htvod.cdn.ngenix.net:443/hls/hd_2020_iskusstvennyy_intellekt__16_ar2_trailer/bw3200000/video.ts/playlist.m3u8
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=3200000,URI="https://a787201989-zabava-htvod.cdn.ngenix.net:443/hls/hd_2020_iskusstvennyy_intellekt__16_ar2_trailer/bw3200000/video.ts/iframes.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=2400000,PROGRAM-ID=1,RESOLUTION=1280x720
https://a787201989-zabava-htvod.cdn.ngenix.net:443/hls/hd_2020_iskusstvennyy_intellekt__16_ar2_trailer/bw2400000/video.ts/playlist.m3u8
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=2400000,URI="https://a787201989-zabava-htvod.cdn.ngenix.net:443/hls/hd_2020_iskusstvennyy_intellekt__16_ar2_trailer/bw2400000/video.ts/iframes.m3u8"
```
This playlist can be found at following url: https://zabava-htvod.cdn.ngenix.net/hls/hd_2020_iskusstvennyy_intellekt__16_ar2_trailer/variant.m3u8
I hope it is accessible from any location but not sure.
In the code of HlsMediaPeriod.java I see following conditions to mark variant as video track:
https://github.com/google/ExoPlayer/blob/03263db378392385e290c40505d80e990c85a5cb/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java#L567
As you can see by these conditions height parameter must be present or type of codec should be video. In my case these parameters are unknown. So, i-frame variants are not presented in video tracks.
I checked that these parameters corresponds to RESOLUTION and CODECS HLS attributes.
But it seems they are not mandatory attributes because HLS RFC has following description:
> Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute.
Here is SHOULD but isn't MUST.
> The RESOLUTION attribute is OPTIONAL but is recommended if the Variant Stream includes video.
RESOLUTION also looks like not mandatory parameters.
Simple fix for this case is to add additional condition to mark it as video if format has trick play flag set.
Possible code can looks like this:
`if (format.height > 0 || Util.getCodecsOfType(format.codecs, C.TRACK_TYPE_VIDEO) != null || (format.roleFlags & C.ROLE_FLAG_TRICK_PLAY) != 0) {`
What do you think?
Contributor guide
Assessment
This issue has not been assessed yet.