Monday, April 4, 2016

HLS 'EVENT' playlists failing to start in players

Leave a Comment

I have HLS playlists that look like this:

#EXTM3U #EXT-X-VERSION:3 #EXT-X-PLAYLIST-TYPE:EVENT #EXT-X-TARGETDURATION:10 #EXT-X-ALLOW-CACHE:NO #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:9.97667, https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence0.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence1.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence2.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence3.ts 

They are of EVENT type, meaning, chunks are appended as they become available, and when all chunks are there, an #EXT-X-ENDLIST tag is appended at the end.

So when all chunks are uploaded, we end up with a playlist that looks something like:

#EXTM3U #EXT-X-VERSION:3 #EXT-X-PLAYLIST-TYPE:EVENT #EXT-X-TARGETDURATION:10 #EXT-X-ALLOW-CACHE:NO #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence0.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence1.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence2.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence3.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence4.ts #EXTINF:9.97667,   https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear1/fileSequence5.ts #EXT-X-ENDLIST 

We are seeing odd behaviour in all our clients. If you open the m3u8 playlist in iOS and Safari when the first chunk (or even after say, 3 chunks) are uploaded, the player will start playing the video as it should. Occasionally it will stop however, and be unable to resume. More often than not, it won't even begin playing.

Fully formed playlists (i.e. with an #EXT-X-ENDLIST tag) play perfectly. It's just when the playlist is partially done.

We have tried a variety of players: Quicktime, Safari, iOS, VLC, Flowplayer etc. All have a variety of issues, but this is the most pressing.

Any insight into where to look in solving this problem would be greatly appreciated.

Edit: We have tried HLS.js and it plays perfectly. Such a nice user experience too

Edit 2: To reproduce, I recommend having some sort of local HTTP server (I use python -m SimpleHTTPServer serving up a playlist above. Then literally append the files to the playlist to simulate the uploading of files, and watch the players break.

2 Answers

Answers 1

The #EXT-X-DISCONTINUITY tag is used to indicate changes in file format, encoding parameters, number of tracks, and so on. If the segments in the playlist are identical in regard to these things, you can remove the #EXT-X-DISCONTINUITY tags from the playlist - you don't need them.

Some clients may not be compatible with version 6 of the protocol. You don't appear to be using any version 6 specific features so try setting the version number to 3 to see if that helps.

Answers 2

try something like this

Simple Media Playlist file

   #EXTM3U    #EXT-X-VERSION:3    #EXT-X-TARGETDURATION:5220    #EXTINF:5219.2,    http://media.example.com/entire.ts    #EXT-X-ENDLIST 

Sliding Window Media Playlist, using HTTPS

 #EXTM3U    #EXT-X-VERSION:3    #EXT-X-TARGETDURATION:8    #EXT-X-MEDIA-SEQUENCE:2680     #EXTINF:7.975,    https://priv.example.com/fileSequence2680.ts    #EXTINF:7.941,    https://priv.example.com/fileSequence2681.ts    #EXTINF:7.975,    https://priv.example.com/fileSequence2682.ts 

Playlist file with encrypted media segments

#EXTM3U    #EXT-X-VERSION:3    #EXT-X-MEDIA-SEQUENCE:7794    #EXT-X-TARGETDURATION:15     #EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=52"     #EXTINF:2.833,    http://media.example.com/fileSequence52-A.ts    #EXTINF:15.0,    http://media.example.com/fileSequence52-B.ts    #EXTINF:13.333,    http://media.example.com/fileSequence52-C.ts     #EXT-X-KEY:METHOD=AES-128,URI="https://priv.example.com/key.php?r=53"     #EXTINF:15.0,    http://media.example.com/fileSequence53-A.ts 

Master Playlist file

#EXTM3U    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1280000    http://example.com/low.m3u8    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2560000    http://example.com/mid.m3u8    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=7680000    http://example.com/hi.m3u8    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=65000,CODECS="mp4a.40.5"    http://example.com/audio-only.m3u8 

Master Playlist with I-Frames In this example, the PROGRAM-ID attributes have been left out:

#EXTM3U    #EXT-X-STREAM-INF:BANDWIDTH=1280000    low/audio-video.m3u8    #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=86000,URI="low/iframe.m3u8"    #EXT-X-STREAM-INF:BANDWIDTH=2560000    mid/audio-video.m3u8    #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=150000,URI="mid/iframe.m3u8"    #EXT-X-STREAM-INF:BANDWIDTH=7680000    hi/audio-video.m3u8    #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=550000,URI="hi/iframe.m3u8"    #EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5"    audio-only.m3u8 

Master Playlist with Alternative audio In this example, the PROGRAM-ID attributes have been left out. The CODECS attributes have been condensed for space. A '\' is used to indicate that the tag continues on the following line with whitespace removed:

   #EXTM3U    #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="English", \       DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en", \       URI="main/english-audio.m3u8"    #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="Deutsch", \       DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="de", \       URI="main/german-audio.m3u8"    #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",NAME="Commentary", \       DEFAULT=NO,AUTOSELECT=NO,URI="commentary/audio-only.m3u8"    #EXT-X-STREAM-INF:BANDWIDTH=1280000,CODECS="...",AUDIO="aac"    low/video-only.m3u8    #EXT-X-STREAM-INF:BANDWIDTH=2560000,CODECS="...",AUDIO="aac"    mid/video-only.m3u8    #EXT-X-STREAM-INF:BANDWIDTH=7680000,CODECS="...",AUDIO="aac"    hi/video-only.m3u8    #EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5",AUDIO="aac"    main/english-audio.m3u8 

Master Playlist with Alternative video

#EXTM3U    #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Main", \       DEFAULT=YES,URI="low/main/audio-video.m3u8"    #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Centerfield", \       DEFAULT=NO,URI="low/centerfield/audio-video.m3u8"    #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Dugout", \       DEFAULT=NO,URI="low/dugout/audio-video.m3u8"     #EXT-X-STREAM-INF:BANDWIDTH=1280000,CODECS="...",VIDEO="low"    low/main/audio-video.m3u8     #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="mid",NAME="Main", \       DEFAULT=YES,URI="mid/main/audio-video.m3u8"    #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="mid",NAME="Centerfield", \       DEFAULT=NO,URI="mid/centerfield/audio-video.m3u8"    #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="mid",NAME="Dugout", \       DEFAULT=NO,URI="mid/dugout/audio-video.m3u8"     #EXT-X-STREAM-INF:BANDWIDTH=2560000,CODECS="...",VIDEO="mid"    mid/main/audio-video.m3u8     #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="hi",NAME="Main", \       DEFAULT=YES,URI="hi/main/audio-video.m3u8"    #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="hi",NAME="Centerfield", \       DEFAULT=NO,URI="hi/centerfield/audio-video.m3u8"    #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="hi",NAME="Dugout", \       DEFAULT=NO,URI="hi/dugout/audio-video.m3u8"     #EXT-X-STREAM-INF:BANDWIDTH=7680000,CODECS="...",VIDEO="hi"    hi/main/audio-video.m3u8     #EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5"    main/audio-only.m3u8 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment