RSS

Recent Comments

Powered by Disqus
Mar
7th
Thu
permalink

HTTP Live Streaming in iOS using AVPlayer

I’ve become very intimate with my video player class recently and we’ve been spending lots of quality time together, in fact just last week I rewrote large parts of her.

She is built on the AVPlayer Class and it’s probably just me, but there were a couple things about this class that was just a bit unclear. Here are some things that I found out that might help someone else:

  1. How do you determine which stream is currently being played by the player? avplayer.currentItem.accessLog.events.lastObject.URI (can’t believe I couldn’t find this out had to read the documentation 3 times before figuring this one out, we actually resorting to burning the stream names into the video files itself to test)
  2. What is the bitrate / bandwidth that the player is seeing / using / reporting / observing? avplayer.currentItem.accessLog.events.lastObject.observedBitrate (AVAssetTrack.estimatedDataRate lead me on a wild goose chase…)
  3. What are the rules for switching between streams? avplayer.currentItem.accessLog.events.lastObject.indicatedBitrate will be the bitrate that you define in your playlist which is paired with each stream. So what I have observed (this was done purely by using Network Link Conditioner to modify my network bandwidth and see which stream was played, not at all scientific) the player will play the default stream (first stream in playlist) and will start observing the bitrate. Once the observed bitrate increases to twice of the next stream’s indicated bitrate, it will switch to that next stream and will remain there until it drops below that indicated bitrate or if it becomes twice the next one, it will switch up again.

This meant a couple of things:

  1. Chose your indicatedBitrate carefully. Let’s assume the Network Link Conditioner’s profiles are correct and that for an average 3G connection the bandwidth is 780kbps, from what I observed the player only really gets 680kpbs so if your stream was indicated as 380kpbs, there is a high chance that someone on an average 3G connection will never be able to play it despite getting as high as 680kbps (will need 760kbps observedbitrate to switch up). So take note of the different network conditions like Edge, 3G and LTE and encode accordingly.
  2. Have more streams to cater to lower bandwidth connections rather that having them equally spaced out. With more people getting cable network speeds, having more streams above 500kpbs doesn’t seem to make a difference visually on the device (airplay is another story). Once users go on Wifi, they can get 2Mbps which would give them really good quality video. The devices that really benefit from HLS are those with low bandwidth and lossy connection. This is where HLS really shines. So have more streams to cater for Edge to 3G instead of 3G to Wifi.

Hopefully this discovery will lead to better quality videos for our users. They are a lovely bunch…

Nov
9th
Fri
permalink
If you’re an unreasonable person, trust me: the time it takes to find the best of something is completely worth it. It’s better to have a few fantastic things designed for you than to have many untrustworthy things poorly designed to please everyone.
Sep
26th
Wed
permalink
Don’t build an app based on your website. Build the app that acts as if websites never existed in the first place. Build the app for the person who has never used a desktop computer. Because they’re coming. Soon.
Sep
23rd
Sun
permalink
Eventually Apple will just make phones out of unicorn horn and the dewy moisture that collects between Scarlett Johansson’s breasts when she does hot yoga. (Technically, any yoga done by Scarlett Johansson is “hot yoga” but I’m specifically talking about Bikram in this case.) The white one will feature the same moisture collected from Michael Fassbender.
permalink
permalink

The iPhone 5 (Parody): A Taller Change Than Expected (by Satire)

Sep
20th
Thu
permalink
Aug
10th
Fri
permalink
Apr
28th
Sat
permalink
Everything will be okay in the end. If it’s not okay, it’s not the end.
Apr
20th
Fri
permalink
There are only two hard things in Computer Science: cache invalidation and naming things.