HLS live stream work for 5 minutes
#1
I'm trying to play a HLS stream and it works only for 5 minutes. After looking for http packets I did realize that the player isn't changing a cookie that is set on every response.
Look for vssession cookie. After 5 minutes every .m3u8 and .ts file returns error 403

Code:
GET /dvr/m/off24ha/master-playlist.m3u8?h=0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg&k=html5&a=F&u=52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d HTTP/1.1
Range: bytes=0-
User-Agent: Kodi/14.1 (Windows NT 10.0; WOW64) App_Bitness/32 Version/14.1-Git:20150129-38e4046
Host: live.hls.globo.com
Accept: */*
Cookie: locksession=
Accept-Charset: UTF-8,*;q=0.8

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 25 Aug 2015 01:19:39 GMT
Content-Type: application/vnd.apple.mpegurl
Content-Length: 573
Connection: keep-alive
Set-Cookie: vssession=cR_S3dMoZipzPbX8eNy0Qw14404658790059058404/dvr/m/off24ha/?0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg|F|52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d; Expires=Tue, 25 Aug 2015 01:24:39 GMT; Path=/dvr/m/off24ha/;
Vary: Accept-Encoding
Expires: Tue, 25 Aug 2015 01:19:41 GMT
Cache-Control: private, max-age=0, no-cache
Set-Cookie: locksession=8171fe6881c99d4d95b53cd0dcf3acd9; Path=/; Max-Age=300

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=264000
off24ha_264/playlist.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=464000
off24ha_464/playlist.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=750000
off24ha_750/playlist.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1264000
off24ha_1264/playlist.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1864000
off24ha_1864/playlist.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2564000
off24ha_2564/playlist.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=64000,CODECS="mp4a.40.2"
off24ha_264/playlist-audio.m3u8

GET /dvr/m/off24ha/off24ha_2564/playlist.m3u8 HTTP/1.1
User-Agent: Kodi/14.1 (Windows NT 10.0; WOW64) App_Bitness/32 Version/14.1-Git:20150129-38e4046
Accept: */*
Connection: close
Host: live.hls.globo.com
Cookie: locksession=8171fe6881c99d4d95b53cd0dcf3acd9; vssession=cR_S3dMoZipzPbX8eNy0Qw14404658790059058404/dvr/m/off24ha/?0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg|F|52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d; locksession=8171fe6881c99d4d95b53cd0dcf3acd9
Icy-MetaData: 1

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 25 Aug 2015 01:23:03 GMT
Content-Type: application/vnd.apple.mpegurl
Content-Length: 750
Connection: close
Set-Cookie: vssession=UPDcUGHKJXpc7LOg8kGzuQ14404660821688619614/dvr/m/off24ha/?0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg|F|52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d; Expires=Tue, 25 Aug 2015 01:28:02 GMT; Path=/dvr/m/off24ha/;
Vary: Accept-Encoding
Expires: Tue, 25 Aug 2015 01:23:05 GMT
Cache-Control: private, max-age=0, no-cache
Set-Cookie: locksession=8171fe6881c99d4d95b53cd0dcf3acd9; Path=/; Max-Age=300

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:171228
#EXTINF:5.0000,
off24ha_2564-1440465725-148687275600.ts
#EXTINF:5.0000,
off24ha_2564-1440465730-148687725600.ts
#EXTINF:5.0000,
off24ha_2564-1440465735-148688175600.ts
#EXTINF:5.0000,
off24ha_2564-1440465740-148688625600.ts
#EXTINF:5.0000,
off24ha_2564-1440465745-148689075600.ts
#EXTINF:5.0000,
off24ha_2564-1440465750-148689525600.ts
#EXTINF:5.0000,
off24ha_2564-1440465755-148689975600.ts
#EXTINF:5.0000,
off24ha_2564-1440465760-148690425600.ts
#EXTINF:5.0000,
off24ha_2564-1440465765-148690875600.ts
#EXTINF:5.0000,
off24ha_2564-1440465770-148691325600.ts
#EXTINF:5.0000,
off24ha_2564-1440465775-148691775600.ts
#EXTINF:5.0000,
off24ha_2564-1440465780-148692225600.ts


GET /dvr/m/off24ha/off24ha_2564/off24ha_2564-1440465730-148687725600.ts HTTP/1.1
User-Agent: Kodi/14.1 (Windows NT 10.0; WOW64) App_Bitness/32 Version/14.1-Git:20150129-38e4046
Accept: */*
Connection: close
Host: live.hls.globo.com
Cookie: locksession=8171fe6881c99d4d95b53cd0dcf3acd9; vssession=cR_S3dMoZipzPbX8eNy0Qw14404658790059058404/dvr/m/off24ha/?0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg|F|52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d; locksession=8171fe6881c99d4d95b53cd0dcf3acd9
Icy-MetaData: 1

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 25 Aug 2015 01:23:03 GMT
Content-Type: video/MP2T
Content-Length: 1690308
Connection: close
Set-Cookie: vssession=Psd_ZJE9VB33-uVq-64xew14404660830665574113/dvr/m/off24ha/?0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg|F|52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d; Expires=Tue, 25 Aug 2015 01:28:03 GMT; Path=/dvr/m/off24ha/;
Expires: Tue, 25 Aug 2015 01:23:02 GMT
Cache-Control: no-cache


GET /dvr/m/off24ha/off24ha_2564/off24ha_2564-1440465735-148688175600.ts HTTP/1.1
User-Agent: Kodi/14.1 (Windows NT 10.0; WOW64) App_Bitness/32 Version/14.1-Git:20150129-38e4046
Accept: */*
Connection: close
Host: live.hls.globo.com
Cookie: locksession=8171fe6881c99d4d95b53cd0dcf3acd9; vssession=cR_S3dMoZipzPbX8eNy0Qw14404658790059058404/dvr/m/off24ha/?0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg|F|52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d; locksession=8171fe6881c99d4d95b53cd0dcf3acd9
Icy-MetaData: 1

HTTP/1.1 200 OK
Server: nginx
Date: Tue, 25 Aug 2015 01:23:08 GMT
Content-Type: video/MP2T
Content-Length: 1570740
Connection: close
Set-Cookie: vssession=DyJ7qHEcnvYHlzSindzYew14404660881076012996/dvr/m/off24ha/?0411440465697761939438414404691735864119652h6rN-AOOhXZcPlp2UCV8Fg|F|52dfc02cdd23810590000f57_605fd6ba-6320-4a5a-b10f-065e5363421d; Expires=Tue, 25 Aug 2015 01:28:08 GMT; Path=/dvr/m/off24ha/;
Expires: Tue, 25 Aug 2015 01:23:07 GMT
Cache-Control: no-cache

The addon just play the video by:
Code:
player = xbmc.Player()
        player.play(stream['url'], item)

Any ideas what might be wrong? Is that a Kodi bug?
Reply
#2
This looks like a FFMpeg issue, so I did open a ticket on FFMpeg.
https://trac.ffmpeg.org/ticket/4808

If someone code in C/C++, please send a PR to this issue. Looks like an easy fix.
Reply
#3
After some time, I was able to fix it. Now just need to update kodi a new ffmpeg version.
Reply
#4
(2015-09-26, 19:09)andrade Wrote: After some time, I was able to fix it. Now just need to update kodi a new ffmpeg version.
Can you explain how you fixed it? Did you urlencode the '|' chars in the cookie?
Reply
#5
The issue was with FFmpeg. I've sent a patch to FFmpeg (https://github.com/FFmpeg/FFmpeg/commit/...316296a78e).
The HLS module wasn't able to handle setcookies during stream, with my patch now every response with setcookie ajusts the cookies of future requests.

But of course I had to force the cookies.
Code:
session = requests.Session()
req = session.get(url)
m3u8_header = { 'Cookie': '; '.join(['%s=%s' % (key, value) for (key, value) in req.cookies.items()]) }
urlvideo = urlvideo + '|' + urllib.urlencode(m3u8_header)
Reply
#6
This is interesting. I've experienced a similar situation where I need to clear/set a session cookie on each response. Thanks.
Reply
#7
(2015-10-02, 02:40)learningit Wrote: This is interesting. I've experienced a similar situation where I need to clear/set a session cookie on each response. Thanks.

For some reason the kodi isn't using the same path as a pure ffmpeg command line. I'm now unable to debug it.
Reply

Logout Mark Read Team Forum Stats Members Help
HLS live stream work for 5 minutes0