Optimizing HTTP Live Streaming (HLS) for Best User Experience 2

Joon Won Lee
2 min readJul 15, 2018

--

Intro

For better understanding and the ability to leverage the AVFoundation capabilities, I watched wwdc18 session 502. And I wanted to deliver the message of optimizing HLS for better user experience.

In the previous article, we’ve learned what to choose for KPI, and how to reduce start time. This article, we will cover how to investigate stall and errors in HLS playback

Investigate stall

Stall can happen and it does happen!.

Listen to stall notification

So, how to detect stalling in your app? There is a notification for stalling. AVPlayerItemPlaybackStalled is a notification name to observe stalling.

Here’s the code example to listen stall notification.

Check AVPlayerItem status, AVPlayerItem Logs

When stall happed, you can observe few things to investigate stall.

First, you can check the AVPlayerItem.isPlaybackLikelyToKeepUp

AVPlayerItem.isPlaybackLikelyToKeepUp is false when stall happen, and you can start loading indicator in that moment.

Secondly, you can find detail logs from AVPlayerITemErrorLog, AVPlayerItemAccessLog. Such as

  • error explanation
  • observedBitrate and indicatedBitrate

Reducing Stalls

To reduce stall, followings should be done.

Provide a full set of bit rate tier

  • Each codec combination needs its own set of tiers

Your content server and CDN must

  • Deliver media playlists, segments, and keys without delay
  • Update live playlists at least every target duration
  • Synchronize discontinuity sequence numbers between playlists
  • Indicate server-side failures clearly

Investigate error

How do we investigate error?

There are few ways to investigate

  • Error and access logs from AVPlayerItem
  • Error properties from AVPlayer, AVPlayerItem
  • Media validation tool to detect content issue

AVPlayerItemErrorLog

  • this might not be fatal error
  • details are in the error comment

ErrorLog examples

  • “Media file not received in 15s”
  • “HTTP404: file not found”
  • “Segment exceeds specified bandwidth for variant”
  • “Unsupported crypt format”

AVPlayer, AVPlayerItem “status” property

  • this might be fatal error
  • AVPlayerItem.Error end playback and remove item from player queue

Media validation tool

  • You can use media validation tool for content issue
  • Available on developer website

Conclusion

In this article, I’ve coverd how to investigate stall and errors.

Here’s the summary

For investigate stall,

  • Listen notification
  • Check AVPlayerItemAccessLog and AVPlayerItemErrorLog

For investigate error,

  • Check AVPlayerItemErrorLog
  • Check AVPlayer and AVPlayerItem’s status
  • Check AVPlayerItem.error

Thank you reading this article. If you have any thought on this, leave a comment. :)

--

--