(2014-11-27, 16:29)sdsnyr94 Wrote: One of the most frustrating things with these NHL addons is the buffering. Unlike the Roku or AppleTV, XBMC/Kodi cannot automatically change playback quality on the fly.... so if there is any type of network lag you will get buffering.
This was also a problem with MLBMC, except when using the HLS version of the addon. The HLS version used an external binary which would pull the feed and create a video file, which then XBMC would begin to play. The nice part of that is you could tell it to start building the file and wait X seconds before beginning playback, creating a buffer.
Any way you can implement a way to create a buffer?
I've been giving this a bit of thought. The short answer is: I'm not sure I have the time to do this, even if I figure out a nice way to do it.
The slightly longer answer is that I sort of have an idea how it can be done. I should point out that I haven't looked at what MLBMC actually does. A typical playlist contains 6 video segments with relative URLs pointing to the video files. Part of what I do for live rewinding is change those relative URLs (/path/to/video.ts) to absolute URLs (
http://nhl-cdn-server/path/to/video.ts), so that my HLS proxy doesn't have to worry about how to deal with the video segments.
So, my idea is simply to not make the URLs absolute so that my HLS proxy serves them. When it gets a request for a video segment (we'll say that file is named 0000.ts), it downloads that file plus the next X seconds/minutes worth of files before returning 0000.ts to XBMC. So, when XBMC gets 0000.ts, the HLS proxy has already downloaded 0000.ts to, say, 0010.ts. It would maintain a sliding window of buffered files. A request for 0000.ts would download up to 0010.ts, 0001.ts would download up to 0011.ts, 0002.ts would download up to 0012.ts, etc. It'd also maybe save 1 minute of video before the current segment, and maybe 10 minutes after the current segment.
There are three problems that are immediately apparent to me with this solution:
1) HTTP timeouts. I would need to make sure XBMC doesn't think that initial connection has died while the HLS proxy is creating the buffer. I'm far from the first person to have to figure out how to keep a connection alive while waiting for a large chunk of data, so I'm sure this can be solved relatively easily.
2) Memory usage and/or storage space requirements. I have some 5000kbps/60fps video segments saved, and each 10 second segment is at least 5MB in size. So, a 10 minute buffer would use at least 300MB of memory and/or disk space. This could be problematic on mobile devices.
3) I feel like I'm constantly strapped for time lately. I expect (hope) this to change sooner rather than later, but it
is currently a factor.
Also, I
really don't want to have to deal with using external binaries for functionality in the add-on. I love that everything that the add-on does currently is platform agnostic. Once external binaries start getting added into the mix, maintenance and releases becomes a lot more challenging.