Roku Twitch: variable bandwidth usage

The Roku got a new official Twitch client recently. It has a remarkably neat trick: variable adjustment of bandwidth usage while playing a stream without interruption. I’ll be watching the stream in what looks to be 480p quality. Then it drops to lower quality: 360p, or 240p, or even the impressionistic smeary stream for mobile devices. Then it pops back up to 480p when it can. All the while playback is uninterrupted. Crucially the audio never cuts out or skips, so the overall viewing experience is remarkably smooth.

Here’s a bandwidth graph of 10 minutes of me watching RiotGames’ official LCS channel yesterday.

Roku Twitch bandwidth graph

My network is capable of 2600 kbits/sec but only for a burst of ~30 seconds. Then I’m throttled back to 1024 kbps for awhile. Here you can see the stream is mostly consuming about 1000 kbps but occasionally enjoys the burst up to 1500 and once even dropped down to 660 or so. All the time that was happening my playback was quite smooth and solid, the only indication anything was going on was that the graphics got a bit fuzzy sometimes.

Most video streaming apps online seem to have one HTTP stream for each quality of video, and once you start streaming it you’re committed to that bitrate. The Twitch app must be doing something smarter about grabbing a few seconds of stream at a time and dynamically altering the bitrate depending on measured bandwidth. That may explain the 3s buffering time before the stream plays, too. I’ll gladly take that tradeoff.

In the long long ago of the early 00s Internet, video streaming was dominated by RealMedia’s proprietary protocol. That was UDP, so packet loss could be handled by the app. And it was a progressive codec. I think Twitch is doing TCP and not a progressive codec, so it’s more like it’s just dynamically altering which stream it asks for on the fly. Seems to work pretty well.

(BTW, Twitch is still coy about publishing details on video quality and bitrates. Their’ partners page has some samples though, which claims

  • 240p: 384kbps
  • 360p: 512kbps
  • 480p: 768kbps
  • 720p: 1161kbps
  • 1080p: 1500kbps

I’m suspicious of the correctness of these numbers. They’re too low, also too much like round numbers except 720p. Maybe the numbers are video only and they’re doing transcoding to exactly hit a video bitrate? Seems unlikely.)