SlideShare a Scribd company logo
1 of 99
Mobile Movies with
                          HTTP Live Streaming
                             Chris Adamson ā€¢ @invalidname
                                      CocoaConf
                             Aug 10, 2012 ā€¢ Columbus, OH




                             Sides and code available on my blog:
                                http://www.subfurther.com/blog

Saturday, August 11, 12
So Many Streaming
                               Apps!




Saturday, August 11, 12
So Many Streaming
                               Apps!




Saturday, August 11, 12
Netļ¬‚ix




Saturday, August 11, 12
Flixter




Saturday, August 11, 12
ABC




Saturday, August 11, 12
PBS




Saturday, August 11, 12
NBC Olympics Live
                               Extra




Saturday, August 11, 12
DirecTV




Saturday, August 11, 12
UStream




Saturday, August 11, 12
Crunchyroll




Saturday, August 11, 12
TwitchTV




Saturday, August 11, 12
Oh, and it can be embedded
                      in the <video> tag




Saturday, August 11, 12
Sounds good? How
                          do I get in on that?




Saturday, August 11, 12
What You'll Learn

                 ā€¢ What streaming is (and isn't)

                 ā€¢ Setting up HLS on the server

                 ā€¢ Using HLS streams in iOS apps

                 ā€¢ Real-world deployment




Saturday, August 11, 12
HLS: What It Is (and
                                isn't)




Saturday, August 11, 12
Good Ol' Broadcast




Saturday, August 11, 12
Broadcast Media

                 ā€¢ Always live on some channel (a band of EM
                   spectrum).

                 ā€¢ Every client tuned to that channel sees the
                   same thing, at the same time.

                 ā€¢ One-way, one-to-many model.




Saturday, August 11, 12
Internet
                 ā€¢ Generally one-to-one (host to host).

                      ā€¢ Multicast IP is an exception, but is rare on
                        the public Internet.

                 ā€¢ Two-way communication over sockets.

                 ā€¢ Routing can take many hops, via multiple
                   transport media (wire, wiļ¬, cellular, etc.).


Saturday, August 11, 12
Impedence Mismatch!




Saturday, August 11, 12
Ye Olde Streaming
                 ā€¢ Client makes socket connection and keeps it
                   open for duration of program.

                 ā€¢ Server sends media at playback speed (plus
                   buffering).

                      ā€¢ Shoutcast: MP3 ļ¬les served slowly over HTTP.

                 ā€¢ Typically use a special port number and
                   special server software.


Saturday, August 11, 12
Streaming Problems
                 ā€¢ Difļ¬cult and expensive to scale.

                 ā€¢ Special port numbers routinely blocked by
                   businesses, ISPs, ļ¬rewalls, etc.

                 ā€¢ Competing standards: Real Player, Windows
                   Media, QuickTime (all with their own plugins).

                          ā€¢ No wonder Flash won.

                 ā€¢ Good luck holding a socket connection on cellular.


Saturday, August 11, 12
What Ifā€¦
                 ā€¢ We didn't need an always-on socket
                   connection?

                 ā€¢ We could just run over port 80?

                 ā€¢ We could just adopt industry standards like H.
                   264 and AAC instead of cooking custom
                   codecs?



Saturday, August 11, 12
HTTP Live Streaming
                 ā€¢ Serves media as a series of short ļ¬‚at ļ¬les, via
                   HTTP, usually on port 80.

                 ā€¢ Any web server will do.

                 ā€¢ Client software reassembles the data into a
                   continuous media stream.

                 ā€¢ Spec does not specify contents, but Apple uses
                   H.264 and AAC, just like all their media apps.


Saturday, August 11, 12
Serving up HLS


                 ā€¢ Client URL is an .m3u8 playlist ļ¬le

                 ā€¢ Playlist points to the media segment ļ¬les




Saturday, August 11, 12
Saturday, August 11, 12
The HLS playlist
      #EXTM3U
      #EXT-X-TARGETDURATION:10
      #EXT-X-VERSION:3
      #EXT-X-MEDIA-SEQUENCE:0
      #EXT-X-PLAYLIST-TYPE:VOD
      #EXTINF:9.975,!
      fileSequence0.ts
      #EXTINF:9.975,!
      fileSequence1.ts
      #EXTINF:9.975,!
      fileSequence2.ts
      #EXTINF:9.9767,!
      fileSequence3.ts
      #EXTINF:9.975,!

      [...]

      #EXT-X-ENDLIST

Saturday, August 11, 12
The HLS playlist
      #EXTM3U                       Format: .m3u8 format,
      #EXT-X-TARGETDURATION:10
      #EXT-X-VERSION:3
                                    just a list of ļ¬les to play
      #EXT-X-MEDIA-SEQUENCE:0
      #EXT-X-PLAYLIST-TYPE:VOD
      #EXTINF:9.975,!
      fileSequence0.ts
      #EXTINF:9.975,!
      fileSequence1.ts
      #EXTINF:9.975,!
      fileSequence2.ts
      #EXTINF:9.9767,!
      fileSequence3.ts
      #EXTINF:9.975,!

      [...]

      #EXT-X-ENDLIST

Saturday, August 11, 12
The HLS playlist
      #EXTM3U                       Format: .m3u8 format,
      #EXT-X-TARGETDURATION:10
      #EXT-X-VERSION:3
                                    just a list of ļ¬les to play
      #EXT-X-MEDIA-SEQUENCE:0
      #EXT-X-PLAYLIST-TYPE:VOD      Metadata tags describe
      #EXTINF:9.975,!
      fileSequence0.ts              the contents
      #EXTINF:9.975,!
      fileSequence1.ts
      #EXTINF:9.975,!
      fileSequence2.ts
      #EXTINF:9.9767,!
      fileSequence3.ts
      #EXTINF:9.975,!

      [...]

      #EXT-X-ENDLIST

Saturday, August 11, 12
The HLS playlist
      #EXTM3U                       Format: .m3u8 format,
      #EXT-X-TARGETDURATION:10
      #EXT-X-VERSION:3
                                    just a list of ļ¬les to play
      #EXT-X-MEDIA-SEQUENCE:0
      #EXT-X-PLAYLIST-TYPE:VOD      Metadata tags describe
      #EXTINF:9.975,!
      fileSequence0.ts              the contents
      #EXTINF:9.975,!
      fileSequence1.ts
      #EXTINF:9.975,!               Each segment ļ¬le
      fileSequence2.ts
      #EXTINF:9.9767,!
                                    preceded by metadata
      fileSequence3.ts              (e.g., duration)
      #EXTINF:9.975,!

      [...]

      #EXT-X-ENDLIST

Saturday, August 11, 12
The HLS playlist
      #EXTM3U                       Format: .m3u8 format,
      #EXT-X-TARGETDURATION:10
      #EXT-X-VERSION:3
                                    just a list of ļ¬les to play
      #EXT-X-MEDIA-SEQUENCE:0
      #EXT-X-PLAYLIST-TYPE:VOD      Metadata tags describe
      #EXTINF:9.975,!
      fileSequence0.ts              the contents
      #EXTINF:9.975,!
      fileSequence1.ts
      #EXTINF:9.975,!               Each segment ļ¬le
      fileSequence2.ts
      #EXTINF:9.9767,!
                                    preceded by metadata
      fileSequence3.ts              (e.g., duration)
      #EXTINF:9.975,!

      [...]                        If no end tag, client
      #EXT-X-ENDLIST               refreshes periodically
Saturday, August 11, 12
Web Demo




Saturday, August 11, 12
<video src="prog_index.m3u8" width="640" height="480"
                   controls autoplay>No video tag support</video>
Saturday, August 11, 12
How is this better than
                        a ļ¬‚at .m4v ļ¬le?
                 ā€¢ Streams can provide variants for different
                   bandwidths (as weā€™ll seeā€¦)

                 ā€¢ Segments make it easier to scrub into the
                   video

                 ā€¢ Streams can be live video




Saturday, August 11, 12
The ā€œLiveā€ in HLS
                 ā€¢ A playlist is a live stream if it doesnā€™t have an
                   #EXT-X-ENDLIST tag

                 ā€¢ Live playlist will generally just contain the last
                   minute or so of segments

                 ā€¢ Client will refresh playlist every minute or so,
                   download whatever segments it doesnā€™t already
                   have, queue them locally

                 ā€¢ ā€œLiveā€ isnā€™t really ā€œliveā€ (often a minute behind)

Saturday, August 11, 12
Serving up HLS




Saturday, August 11, 12
Saturday, August 11, 12
Saturday, August 11, 12
Saturday, August 11, 12
Saturday, August 11, 12
Saturday, August 11, 12
mediaļ¬lesegmenter
                 ā€¢ Splits an A/V ļ¬le into segment ļ¬les, creates
                   the .m3u8 playlist

                 ā€¢ Source must be .mov or .m4v with H.264 video,
                   AAC audio

                 ā€¢ Output segments will be MPEG-2 Transport Stream
                   (.ts) ļ¬les, or .aac if audio-only

                 ā€¢ Segment paths are relative, use -b to prepend URL
                   stub


Saturday, August 11, 12
Technical Note TN2224
        The following audio and video formats are supported:

        ā€¢ Video: H.264 Baseline Proļ¬le Level 3.0 (iPhone/iPod Touch),
          Main Proļ¬le Level 3.1 (iPad 1,2)

        ā€¢ Audio: HE-AAC or AAC-LC up to 48 kHz, stereo audio OR
          MP3 (MPEG-1 Audio Layer 3) 8 kHz to 48 kHz, stereo audio

        Note: iPhone 3G supports Baseline Proļ¬le Level 3.1. If your
        app runs on older iPhones, however, you should use H.264
        Baseline Proļ¬le 3.0 for compatibility.


Saturday, August 11, 12
Yuna:HTTP Live Streaming tests cadamson$ mediafilesegmenter
             -f basic source/IMG_0251.MOV
             Jun 24 2012 10:01:24.203: Using floating point is not
             backward compatible to iOS 4.1 or earlier devices
             Jun 24 2012 10:01:24.204: Processing file /Users/cadamson/
             Documents/HTTP Live Streaming tests/source/IMG_0251.MOV
             Jun 24 2012 10:01:24.338: Finalized /Users/cadamson/
             Documents/HTTP Live Streaming tests/basic/fileSequence0.ts
             Jun 24 2012 10:01:24.375: segment bitrate 3.78028e+06 is
             new max
             Jun 24 2012 10:01:24.468: Finalized /Users/cadamson/
             Documents/HTTP Live Streaming tests/basic/fileSequence1.ts
             Jun 24 2012 10:01:24.554: Finalized /Users/cadamson/
             Documents/HTTP Live Streaming tests/basic/fileSequence2.ts
             Jun 24 2012 10:01:24.631: Finalized /Users/cadamson/
             Documents/HTTP Live Streaming tests/basic/fileSequence3.ts
             Jun 24 2012 10:01:24.717: Finalized /Users/cadamson/
             Documents/HTTP Live Streaming tests/basic/fileSequence4.ts




Saturday, August 11, 12
Demo




Saturday, August 11, 12
Variant Playlists
                 ā€¢ One bitrate does not ļ¬t all: Mac on Ethernet
                   versus iPhone on Edge.

                 ā€¢ Solution: encode your video at multiple bitrates,
                   offer metadata in playlist about what's
                   available, let client ļ¬gure out which to use.

                 ā€¢ HLS clients automatically switch to best variant
                   for current network conditions, switch on the ļ¬‚y.



Saturday, August 11, 12
variantplaylistcreator
                 ā€¢ Creates a playlist that itself points to playlists
                   created with mediaļ¬lesegmenter.

                      ā€¢ Each entry contains metadata describing the
                        bitrate and encoding of the variant.

                 ā€¢ Tool takes argument pairs: ļ¬le or URL of a
                   variant .m3u8, and metadata .plist created with
                   mediaļ¬lesegmenter -I ļ¬‚ag

                 ā€¢ First entry in variant playlist is default; client will try
                   this one ļ¬rst

Saturday, August 11, 12
Encoding the variants




Saturday, August 11, 12
TN2224
                          Recommendations




Saturday, August 11, 12
Creating variants
            Yuna:HTTP Live Streaming tests cadamson$
            mediafilesegmenter -I -f variants/
            broadband/ source/IMG_0254_Broadband.m4v

           Yuna:HTTP Live Streaming tests cadamson$
           mediafilesegmenter -I -f variants/wifi
           source/IMG_0254_WiFi.m4v

            Yuna:HTTP Live Streaming tests cadamson$
            mediafilesegmenter -I -f variants/
            cellular source/IMG_0254_Cellular.m4v


Saturday, August 11, 12
Creating variant playlist
          Yuna:HTTP Live Streaming tests cadamson$
          variantplaylistcreator -o variants/
          variants.m3u8 variants/broadband/
          prog_index.m3u8 source/
          IMG_0254_Broadband.plist variants/wifi/
          prog_index.m3u8 source/
          IMG_0254_WiFi.plist variants/cellular/
          prog_index.m3u8 source/
          IMG_0254_Cellular.plist



Saturday, August 11, 12
Demo




Saturday, August 11, 12
That's Great, butā€¦
                          How do we keep people from stealing our stream?




Saturday, August 11, 12
Encryption
                 ā€¢ HLS encrypts ļ¬les, not transport.

                 ā€¢ Easy to scale: still serving ļ¬‚at ļ¬les, but now
                   they're useless without decryption keys.

                 ā€¢ Serving the keys still needs to be secure.

                 ā€¢ Necessary, but not sufļ¬cient, for DRM.



Saturday, August 11, 12
Encrypting a playlist
    Yuna:HTTP Live Streaming tests cadamson$ mediafilesegmenter -
    I -k keys -f encrypted/cellular source/IMG_0426_Cellular.m4v
    Jun 24 2012 18:59:47.115: Using new key/iv rotation period;
    this is not backward compatible to iOS 3.1.* or earlier
    devices. Ā Use the "-encrypt-iv=sequence" option for
    compatibility with those devices.
    Jun 24 2012 18:59:47.115: Using floating point is not
    backward compatible to iOS 4.1 or earlier devices
    Jun 24 2012 18:59:47.115: Processing file /Users/cadamson/
    Documents/HTTP Live Streaming tests/source/
    IMG_0426_Cellular.m4v
    Jun 24 2012 18:59:47.152: changing IV
    Jun 24 2012 18:59:47.160: Finalized /Users/cadamson/
    Documents/HTTP Live Streaming tests/encrypted/cellular/
    fileSequence0.ts
    Jun 24 2012 18:59:47.160: segment bitrate 271257 is new max


Saturday, August 11, 12
Encrypted .ts ļ¬les




Saturday, August 11, 12
Encrypted .ts ļ¬les




Saturday, August 11, 12
Encrypted .ts ļ¬les




Saturday, August 11, 12
Encrypted .ts ļ¬les




Saturday, August 11, 12
Protect those keys




                          /www/protected


                                           /www/hls



Saturday, August 11, 12
Demo




Saturday, August 11, 12
Live Streaming

                 ā€¢ mediastreamsegmenter mostly works like the
                   ļ¬le version, but takes its input from UDP
                   stream or a Unix pipe

                 ā€¢ How the heck do you create a UDP A/V
                   stream?




Saturday, August 11, 12
VLC streams .ts/UDP




                          http://stackoverļ¬‚ow.com/questions/3846145
Saturday, August 11, 12
VLC streams .ts/UDP

      mediastreamsegmenter -s 3 -D -f /Library/
      WebServer/Documents/httplivestreaming/live
      127.0.0.1:1234




                          http://stackoverļ¬‚ow.com/questions/3846145
Saturday, August 11, 12
Demo (Or Not)




Saturday, August 11, 12
Client-side HLS




Saturday, August 11, 12
Opening an HLS
                             stream

                 ā€¢ Provide the .m3u8 URL to
                   MPMoviePlayerController or AVPlayer

                 ā€¢ Add the movie view or layer to your UI,
                   customizing size or scaling if necessary




Saturday, August 11, 12
MPMoviePlayerController

   // create new movie player
   self.moviePlayer = [[MPMoviePlayerController alloc]
   ! ! ! ! ! ! ! ! initWithContentURL:streamURL];
   [self.moviePlayer prepareToPlay];
   [self.moviePlayer.view setFrame:
   ! ! ! ! ! ! ! self.movieContainerView.bounds];
   [self.movieContainerView addSubview:
   ! ! ! ! ! ! ! ! self.moviePlayer.view];
   self.moviePlayer.scalingMode =
   ! ! ! ! ! ! ! ! MPMovieScalingModeFill;




Saturday, August 11, 12
MPMovieScalingMode
                         AspectFit




Saturday, August 11, 12
MPMovieScalingMode
                         AspectFill




Saturday, August 11, 12
MPMovieScalingModeĀ 
                            Fill




Saturday, August 11, 12
Accessing Encrypted
                               Streams
                 ā€¢ Media Player and AV Foundation can use
                   NSURLCredentials that you've provided

                 ā€¢ Place credentials in NSURLCredentialStorage

                 ā€¢ Server can provide the keys securely(*) with
                   HTTP Basic or Digest authentication, an
                   HTTPS script, etc.

                            * - For various values of "secure"

Saturday, August 11, 12
Setting credentials (1)

       NSURLProtectionSpace *protectionSpace =
       ! [[NSURLProtectionSpace alloc]
       ! ! initWithHost:host
       ! ! port:port
       ! ! protocol:protocol
       ! ! realm:realm
       ! ! authenticationMethod:
       ! ! ! NSURLAuthenticationMethodDefault];




Saturday, August 11, 12
Setting credentials (2)

          NSURLCredential *credential =
          ! [NSURLCredential credentialWithUser:username
          ! ! ! ! ! ! ! ! ! Ā  Ā  Ā  Ā  password:password
          ! ! ! ! ! ! ! ! ! ! ! persistence:
          ! ! ! NSURLCredentialPersistenceForSession];

          [[NSURLCredentialStorage
          ! sharedCredentialStorage]
          ! ! setDefaultCredential:credential
          ! !    forProtectionSpace:protectionSpace];



Saturday, August 11, 12
Streaming in the Real
                            World
                          It's not all about iPhonesā€¦




Saturday, August 11, 12
Streaming Clients
                 ā€¢ Mobile Devices: iPhone, iPad, iPod Touchā€¦
                   plus Android, Windows Mobile, etc.

                 ā€¢ Mac and Windows PCs

                 ā€¢ Over-the-top (OTT) boxes: Apple TV, Roku

                 ā€¢ Game consoles



Saturday, August 11, 12
Let's Get Practical

                 ā€¢ What devices do you have to be on?

                 ā€¢ What devices will you get for free?

                 ā€¢ How to encode and deliver to the devices you
                   need?




Saturday, August 11, 12
HLS Alternatives
                 ā€¢ Flash still rules on the desktop/browser
                   space, thanks in part to Mozilla's obstinance
                   about H.264 in <video> (irony alert: H.264 is
                   the de facto standard for Flash video)

                 ā€¢ Adobe Dynamic Streaming and Microsoft
                   Smooth Streaming are highly similar to HLS:
                   bitrate-adaptive streams over HTTP



Saturday, August 11, 12
MPEG-DASH
                 ā€¢ Attempt at a standardized approach to HTTP
                   adaptive-bitrate streaming. ISO/IEC 23009-1.




                              http://xkcd.com/927/
Saturday, August 11, 12
Emerging Consensus

                 ā€¢ Flash for PCs

                 ā€¢ HTTP Live Streaming for iOS

                 ā€¢ Plus whatever other devices you need to
                   support




Saturday, August 11, 12
Real-World HLS

                 ā€¢ Can you competently encode all your media
                   at all the variant bitrates you need?

                 ā€¢ Do you have a way to QC all your streams?

                 ā€¢ Can you handle the server load?




Saturday, August 11, 12
Content Delivery
                             Networks




         http://en.wikipedia.org/wiki/Content_delivery_network
Saturday, August 11, 12
Content Delivery
                             Networks
                 ā€¢ CDNs host your media on edge servers that are
                   closer to your clients. Less strain on your
                   servers and the backbones.

                 ā€¢ Examples: Akamai, Limelight, EdgeCast

                 ā€¢ Big media companies may have their own CDN

                 ā€¢ Most already know how to do HLS



Saturday, August 11, 12
Buy or Build




Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Outsourcing HLS




                          Ads from "Streaming Media" June/July 2012
Saturday, August 11, 12
Takeaways
                 ā€¢ HLS is a very practical streaming solution

                 ā€¢ Only part of the picture if you're multi-platform

                 ā€¢ Encoding and serving correctly requires some
                   care and expertise

                 ā€¢ Client-side software requirements are fairly
                   simple


Saturday, August 11, 12
Q&A
                          Slides and code will be available on my blog:
                                  http://www.subfurther.com/blog
                              http://www.slideshare.net/invalidname

                                         @invalidname




Saturday, August 11, 12

More Related Content

More from Chris Adamson

Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)Chris Adamson
Ā 
Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)Chris Adamson
Ā 
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)Chris Adamson
Ā 
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Chris Adamson
Ā 
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)Chris Adamson
Ā 
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...Chris Adamson
Ā 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Chris Adamson
Ā 
Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Chris Adamson
Ā 
Stupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasStupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasChris Adamson
Ā 
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)Chris Adamson
Ā 
Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Chris Adamson
Ā 
Stupid Video Tricks
Stupid Video TricksStupid Video Tricks
Stupid Video TricksChris Adamson
Ā 
Introduction to the Roku SDK
Introduction to the Roku SDKIntroduction to the Roku SDK
Introduction to the Roku SDKChris Adamson
Ā 
Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)Chris Adamson
Ā 
Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)Chris Adamson
Ā 
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)Chris Adamson
Ā 
iOS Media APIs (MobiDevDay Detroit, May 2013)
iOS Media APIs (MobiDevDay Detroit, May 2013)iOS Media APIs (MobiDevDay Detroit, May 2013)
iOS Media APIs (MobiDevDay Detroit, May 2013)Chris Adamson
Ā 
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Chris Adamson
Ā 
Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Chris Adamson
Ā 
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)Chris Adamson
Ā 

More from Chris Adamson (20)

Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Building A Streaming Apple TV App (CocoaConf San Jose, Nov 2016)
Ā 
Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)Firebase: Totally Not Parse All Over Again (Unless It Is)
Firebase: Totally Not Parse All Over Again (Unless It Is)
Ā 
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Building A Streaming Apple TV App (CocoaConf DC, Sept 2016)
Ā 
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Video Killed the Rolex Star (CocoaConf San Jose, November, 2015)
Ā 
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Video Killed the Rolex Star (CocoaConf Columbus, July 2015)
Ā 
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Revenge of the 80s: Cut/Copy/Paste, Undo/Redo, and More Big Hits (CocoaConf C...
Ā 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Ā 
Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014Stupid Video Tricks, CocoaConf Seattle 2014
Stupid Video Tricks, CocoaConf Seattle 2014
Ā 
Stupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las VegasStupid Video Tricks, CocoaConf Las Vegas
Stupid Video Tricks, CocoaConf Las Vegas
Ā 
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Core Image: The Most Fun API You're Not Using (CocoaConf Columbus 2014)
Ā 
Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)Stupid Video Tricks (CocoaConf DC, March 2014)
Stupid Video Tricks (CocoaConf DC, March 2014)
Ā 
Stupid Video Tricks
Stupid Video TricksStupid Video Tricks
Stupid Video Tricks
Ā 
Introduction to the Roku SDK
Introduction to the Roku SDKIntroduction to the Roku SDK
Introduction to the Roku SDK
Ā 
Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)Get On The Audiobus (CocoaConf Atlanta, November 2013)
Get On The Audiobus (CocoaConf Atlanta, November 2013)
Ā 
Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)Get On The Audiobus (CocoaConf Boston, October 2013)
Get On The Audiobus (CocoaConf Boston, October 2013)
Ā 
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Ā 
iOS Media APIs (MobiDevDay Detroit, May 2013)
iOS Media APIs (MobiDevDay Detroit, May 2013)iOS Media APIs (MobiDevDay Detroit, May 2013)
iOS Media APIs (MobiDevDay Detroit, May 2013)
Ā 
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013) Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Core Audio in iOS 6 (CocoaConf San Jose, April 2013)
Ā 
Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)Core Audio in iOS 6 (CocoaConf DC, March 2013)
Core Audio in iOS 6 (CocoaConf DC, March 2013)
Ā 
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
Mobile Movies with HTTP Live Streaming (CocoaConf DC, March 2013)
Ā 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
Ā 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
Ā 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...gurkirankumar98700
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
Ā 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
Ā 
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024BookNet Canada
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
Ā 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
Ā 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
Ā 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
Ā 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Ā 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
Ā 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Ā 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
Ā 
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
Ā 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Ā 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
Ā 

Mobile Movies with HTTP Live Streaming (CocoaConf Columbus, Aug '12)

  • 1. Mobile Movies with HTTP Live Streaming Chris Adamson ā€¢ @invalidname CocoaConf Aug 10, 2012 ā€¢ Columbus, OH Sides and code available on my blog: http://www.subfurther.com/blog Saturday, August 11, 12
  • 2. So Many Streaming Apps! Saturday, August 11, 12
  • 3. So Many Streaming Apps! Saturday, August 11, 12
  • 8. NBC Olympics Live Extra Saturday, August 11, 12
  • 13. Oh, and it can be embedded in the <video> tag Saturday, August 11, 12
  • 14. Sounds good? How do I get in on that? Saturday, August 11, 12
  • 15. What You'll Learn ā€¢ What streaming is (and isn't) ā€¢ Setting up HLS on the server ā€¢ Using HLS streams in iOS apps ā€¢ Real-world deployment Saturday, August 11, 12
  • 16. HLS: What It Is (and isn't) Saturday, August 11, 12
  • 18. Broadcast Media ā€¢ Always live on some channel (a band of EM spectrum). ā€¢ Every client tuned to that channel sees the same thing, at the same time. ā€¢ One-way, one-to-many model. Saturday, August 11, 12
  • 19. Internet ā€¢ Generally one-to-one (host to host). ā€¢ Multicast IP is an exception, but is rare on the public Internet. ā€¢ Two-way communication over sockets. ā€¢ Routing can take many hops, via multiple transport media (wire, wiļ¬, cellular, etc.). Saturday, August 11, 12
  • 21. Ye Olde Streaming ā€¢ Client makes socket connection and keeps it open for duration of program. ā€¢ Server sends media at playback speed (plus buffering). ā€¢ Shoutcast: MP3 ļ¬les served slowly over HTTP. ā€¢ Typically use a special port number and special server software. Saturday, August 11, 12
  • 22. Streaming Problems ā€¢ Difļ¬cult and expensive to scale. ā€¢ Special port numbers routinely blocked by businesses, ISPs, ļ¬rewalls, etc. ā€¢ Competing standards: Real Player, Windows Media, QuickTime (all with their own plugins). ā€¢ No wonder Flash won. ā€¢ Good luck holding a socket connection on cellular. Saturday, August 11, 12
  • 23. What Ifā€¦ ā€¢ We didn't need an always-on socket connection? ā€¢ We could just run over port 80? ā€¢ We could just adopt industry standards like H. 264 and AAC instead of cooking custom codecs? Saturday, August 11, 12
  • 24. HTTP Live Streaming ā€¢ Serves media as a series of short ļ¬‚at ļ¬les, via HTTP, usually on port 80. ā€¢ Any web server will do. ā€¢ Client software reassembles the data into a continuous media stream. ā€¢ Spec does not specify contents, but Apple uses H.264 and AAC, just like all their media apps. Saturday, August 11, 12
  • 25. Serving up HLS ā€¢ Client URL is an .m3u8 playlist ļ¬le ā€¢ Playlist points to the media segment ļ¬les Saturday, August 11, 12
  • 27. The HLS playlist #EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-PLAYLIST-TYPE:VOD #EXTINF:9.975,! fileSequence0.ts #EXTINF:9.975,! fileSequence1.ts #EXTINF:9.975,! fileSequence2.ts #EXTINF:9.9767,! fileSequence3.ts #EXTINF:9.975,! [...] #EXT-X-ENDLIST Saturday, August 11, 12
  • 28. The HLS playlist #EXTM3U Format: .m3u8 format, #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 just a list of ļ¬les to play #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-PLAYLIST-TYPE:VOD #EXTINF:9.975,! fileSequence0.ts #EXTINF:9.975,! fileSequence1.ts #EXTINF:9.975,! fileSequence2.ts #EXTINF:9.9767,! fileSequence3.ts #EXTINF:9.975,! [...] #EXT-X-ENDLIST Saturday, August 11, 12
  • 29. The HLS playlist #EXTM3U Format: .m3u8 format, #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 just a list of ļ¬les to play #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-PLAYLIST-TYPE:VOD Metadata tags describe #EXTINF:9.975,! fileSequence0.ts the contents #EXTINF:9.975,! fileSequence1.ts #EXTINF:9.975,! fileSequence2.ts #EXTINF:9.9767,! fileSequence3.ts #EXTINF:9.975,! [...] #EXT-X-ENDLIST Saturday, August 11, 12
  • 30. The HLS playlist #EXTM3U Format: .m3u8 format, #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 just a list of ļ¬les to play #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-PLAYLIST-TYPE:VOD Metadata tags describe #EXTINF:9.975,! fileSequence0.ts the contents #EXTINF:9.975,! fileSequence1.ts #EXTINF:9.975,! Each segment ļ¬le fileSequence2.ts #EXTINF:9.9767,! preceded by metadata fileSequence3.ts (e.g., duration) #EXTINF:9.975,! [...] #EXT-X-ENDLIST Saturday, August 11, 12
  • 31. The HLS playlist #EXTM3U Format: .m3u8 format, #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 just a list of ļ¬les to play #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-PLAYLIST-TYPE:VOD Metadata tags describe #EXTINF:9.975,! fileSequence0.ts the contents #EXTINF:9.975,! fileSequence1.ts #EXTINF:9.975,! Each segment ļ¬le fileSequence2.ts #EXTINF:9.9767,! preceded by metadata fileSequence3.ts (e.g., duration) #EXTINF:9.975,! [...] If no end tag, client #EXT-X-ENDLIST refreshes periodically Saturday, August 11, 12
  • 33. <video src="prog_index.m3u8" width="640" height="480" controls autoplay>No video tag support</video> Saturday, August 11, 12
  • 34. How is this better than a ļ¬‚at .m4v ļ¬le? ā€¢ Streams can provide variants for different bandwidths (as weā€™ll seeā€¦) ā€¢ Segments make it easier to scrub into the video ā€¢ Streams can be live video Saturday, August 11, 12
  • 35. The ā€œLiveā€ in HLS ā€¢ A playlist is a live stream if it doesnā€™t have an #EXT-X-ENDLIST tag ā€¢ Live playlist will generally just contain the last minute or so of segments ā€¢ Client will refresh playlist every minute or so, download whatever segments it doesnā€™t already have, queue them locally ā€¢ ā€œLiveā€ isnā€™t really ā€œliveā€ (often a minute behind) Saturday, August 11, 12
  • 36. Serving up HLS Saturday, August 11, 12
  • 42. mediaļ¬lesegmenter ā€¢ Splits an A/V ļ¬le into segment ļ¬les, creates the .m3u8 playlist ā€¢ Source must be .mov or .m4v with H.264 video, AAC audio ā€¢ Output segments will be MPEG-2 Transport Stream (.ts) ļ¬les, or .aac if audio-only ā€¢ Segment paths are relative, use -b to prepend URL stub Saturday, August 11, 12
  • 43. Technical Note TN2224 The following audio and video formats are supported: ā€¢ Video: H.264 Baseline Proļ¬le Level 3.0 (iPhone/iPod Touch), Main Proļ¬le Level 3.1 (iPad 1,2) ā€¢ Audio: HE-AAC or AAC-LC up to 48 kHz, stereo audio OR MP3 (MPEG-1 Audio Layer 3) 8 kHz to 48 kHz, stereo audio Note: iPhone 3G supports Baseline Proļ¬le Level 3.1. If your app runs on older iPhones, however, you should use H.264 Baseline Proļ¬le 3.0 for compatibility. Saturday, August 11, 12
  • 44. Yuna:HTTP Live Streaming tests cadamson$ mediafilesegmenter -f basic source/IMG_0251.MOV Jun 24 2012 10:01:24.203: Using floating point is not backward compatible to iOS 4.1 or earlier devices Jun 24 2012 10:01:24.204: Processing file /Users/cadamson/ Documents/HTTP Live Streaming tests/source/IMG_0251.MOV Jun 24 2012 10:01:24.338: Finalized /Users/cadamson/ Documents/HTTP Live Streaming tests/basic/fileSequence0.ts Jun 24 2012 10:01:24.375: segment bitrate 3.78028e+06 is new max Jun 24 2012 10:01:24.468: Finalized /Users/cadamson/ Documents/HTTP Live Streaming tests/basic/fileSequence1.ts Jun 24 2012 10:01:24.554: Finalized /Users/cadamson/ Documents/HTTP Live Streaming tests/basic/fileSequence2.ts Jun 24 2012 10:01:24.631: Finalized /Users/cadamson/ Documents/HTTP Live Streaming tests/basic/fileSequence3.ts Jun 24 2012 10:01:24.717: Finalized /Users/cadamson/ Documents/HTTP Live Streaming tests/basic/fileSequence4.ts Saturday, August 11, 12
  • 46. Variant Playlists ā€¢ One bitrate does not ļ¬t all: Mac on Ethernet versus iPhone on Edge. ā€¢ Solution: encode your video at multiple bitrates, offer metadata in playlist about what's available, let client ļ¬gure out which to use. ā€¢ HLS clients automatically switch to best variant for current network conditions, switch on the ļ¬‚y. Saturday, August 11, 12
  • 47. variantplaylistcreator ā€¢ Creates a playlist that itself points to playlists created with mediaļ¬lesegmenter. ā€¢ Each entry contains metadata describing the bitrate and encoding of the variant. ā€¢ Tool takes argument pairs: ļ¬le or URL of a variant .m3u8, and metadata .plist created with mediaļ¬lesegmenter -I ļ¬‚ag ā€¢ First entry in variant playlist is default; client will try this one ļ¬rst Saturday, August 11, 12
  • 49. TN2224 Recommendations Saturday, August 11, 12
  • 50. Creating variants Yuna:HTTP Live Streaming tests cadamson$ mediafilesegmenter -I -f variants/ broadband/ source/IMG_0254_Broadband.m4v Yuna:HTTP Live Streaming tests cadamson$ mediafilesegmenter -I -f variants/wifi source/IMG_0254_WiFi.m4v Yuna:HTTP Live Streaming tests cadamson$ mediafilesegmenter -I -f variants/ cellular source/IMG_0254_Cellular.m4v Saturday, August 11, 12
  • 51. Creating variant playlist Yuna:HTTP Live Streaming tests cadamson$ variantplaylistcreator -o variants/ variants.m3u8 variants/broadband/ prog_index.m3u8 source/ IMG_0254_Broadband.plist variants/wifi/ prog_index.m3u8 source/ IMG_0254_WiFi.plist variants/cellular/ prog_index.m3u8 source/ IMG_0254_Cellular.plist Saturday, August 11, 12
  • 53. That's Great, butā€¦ How do we keep people from stealing our stream? Saturday, August 11, 12
  • 54. Encryption ā€¢ HLS encrypts ļ¬les, not transport. ā€¢ Easy to scale: still serving ļ¬‚at ļ¬les, but now they're useless without decryption keys. ā€¢ Serving the keys still needs to be secure. ā€¢ Necessary, but not sufļ¬cient, for DRM. Saturday, August 11, 12
  • 55. Encrypting a playlist Yuna:HTTP Live Streaming tests cadamson$ mediafilesegmenter - I -k keys -f encrypted/cellular source/IMG_0426_Cellular.m4v Jun 24 2012 18:59:47.115: Using new key/iv rotation period; this is not backward compatible to iOS 3.1.* or earlier devices. Ā Use the "-encrypt-iv=sequence" option for compatibility with those devices. Jun 24 2012 18:59:47.115: Using floating point is not backward compatible to iOS 4.1 or earlier devices Jun 24 2012 18:59:47.115: Processing file /Users/cadamson/ Documents/HTTP Live Streaming tests/source/ IMG_0426_Cellular.m4v Jun 24 2012 18:59:47.152: changing IV Jun 24 2012 18:59:47.160: Finalized /Users/cadamson/ Documents/HTTP Live Streaming tests/encrypted/cellular/ fileSequence0.ts Jun 24 2012 18:59:47.160: segment bitrate 271257 is new max Saturday, August 11, 12
  • 60. Protect those keys /www/protected /www/hls Saturday, August 11, 12
  • 62. Live Streaming ā€¢ mediastreamsegmenter mostly works like the ļ¬le version, but takes its input from UDP stream or a Unix pipe ā€¢ How the heck do you create a UDP A/V stream? Saturday, August 11, 12
  • 63. VLC streams .ts/UDP http://stackoverļ¬‚ow.com/questions/3846145 Saturday, August 11, 12
  • 64. VLC streams .ts/UDP mediastreamsegmenter -s 3 -D -f /Library/ WebServer/Documents/httplivestreaming/live 127.0.0.1:1234 http://stackoverļ¬‚ow.com/questions/3846145 Saturday, August 11, 12
  • 65. Demo (Or Not) Saturday, August 11, 12
  • 67. Opening an HLS stream ā€¢ Provide the .m3u8 URL to MPMoviePlayerController or AVPlayer ā€¢ Add the movie view or layer to your UI, customizing size or scaling if necessary Saturday, August 11, 12
  • 68. MPMoviePlayerController // create new movie player self.moviePlayer = [[MPMoviePlayerController alloc] ! ! ! ! ! ! ! ! initWithContentURL:streamURL]; [self.moviePlayer prepareToPlay]; [self.moviePlayer.view setFrame: ! ! ! ! ! ! ! self.movieContainerView.bounds]; [self.movieContainerView addSubview: ! ! ! ! ! ! ! ! self.moviePlayer.view]; self.moviePlayer.scalingMode = ! ! ! ! ! ! ! ! MPMovieScalingModeFill; Saturday, August 11, 12
  • 69. MPMovieScalingMode AspectFit Saturday, August 11, 12
  • 70. MPMovieScalingMode AspectFill Saturday, August 11, 12
  • 71. MPMovieScalingModeĀ  Fill Saturday, August 11, 12
  • 72. Accessing Encrypted Streams ā€¢ Media Player and AV Foundation can use NSURLCredentials that you've provided ā€¢ Place credentials in NSURLCredentialStorage ā€¢ Server can provide the keys securely(*) with HTTP Basic or Digest authentication, an HTTPS script, etc. * - For various values of "secure" Saturday, August 11, 12
  • 73. Setting credentials (1) NSURLProtectionSpace *protectionSpace = ! [[NSURLProtectionSpace alloc] ! ! initWithHost:host ! ! port:port ! ! protocol:protocol ! ! realm:realm ! ! authenticationMethod: ! ! ! NSURLAuthenticationMethodDefault]; Saturday, August 11, 12
  • 74. Setting credentials (2) NSURLCredential *credential = ! [NSURLCredential credentialWithUser:username ! ! ! ! ! ! ! ! ! Ā  Ā  Ā  Ā  password:password ! ! ! ! ! ! ! ! ! ! ! persistence: ! ! ! NSURLCredentialPersistenceForSession]; [[NSURLCredentialStorage ! sharedCredentialStorage] ! ! setDefaultCredential:credential ! ! forProtectionSpace:protectionSpace]; Saturday, August 11, 12
  • 75. Streaming in the Real World It's not all about iPhonesā€¦ Saturday, August 11, 12
  • 76. Streaming Clients ā€¢ Mobile Devices: iPhone, iPad, iPod Touchā€¦ plus Android, Windows Mobile, etc. ā€¢ Mac and Windows PCs ā€¢ Over-the-top (OTT) boxes: Apple TV, Roku ā€¢ Game consoles Saturday, August 11, 12
  • 77. Let's Get Practical ā€¢ What devices do you have to be on? ā€¢ What devices will you get for free? ā€¢ How to encode and deliver to the devices you need? Saturday, August 11, 12
  • 78. HLS Alternatives ā€¢ Flash still rules on the desktop/browser space, thanks in part to Mozilla's obstinance about H.264 in <video> (irony alert: H.264 is the de facto standard for Flash video) ā€¢ Adobe Dynamic Streaming and Microsoft Smooth Streaming are highly similar to HLS: bitrate-adaptive streams over HTTP Saturday, August 11, 12
  • 79. MPEG-DASH ā€¢ Attempt at a standardized approach to HTTP adaptive-bitrate streaming. ISO/IEC 23009-1. http://xkcd.com/927/ Saturday, August 11, 12
  • 80. Emerging Consensus ā€¢ Flash for PCs ā€¢ HTTP Live Streaming for iOS ā€¢ Plus whatever other devices you need to support Saturday, August 11, 12
  • 81. Real-World HLS ā€¢ Can you competently encode all your media at all the variant bitrates you need? ā€¢ Do you have a way to QC all your streams? ā€¢ Can you handle the server load? Saturday, August 11, 12
  • 82. Content Delivery Networks http://en.wikipedia.org/wiki/Content_delivery_network Saturday, August 11, 12
  • 83. Content Delivery Networks ā€¢ CDNs host your media on edge servers that are closer to your clients. Less strain on your servers and the backbones. ā€¢ Examples: Akamai, Limelight, EdgeCast ā€¢ Big media companies may have their own CDN ā€¢ Most already know how to do HLS Saturday, August 11, 12
  • 84. Buy or Build Saturday, August 11, 12
  • 85. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 86. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 87. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 88. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 89. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 90. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 91. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 92. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 93. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 94. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 95. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 96. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 97. Outsourcing HLS Ads from "Streaming Media" June/July 2012 Saturday, August 11, 12
  • 98. Takeaways ā€¢ HLS is a very practical streaming solution ā€¢ Only part of the picture if you're multi-platform ā€¢ Encoding and serving correctly requires some care and expertise ā€¢ Client-side software requirements are fairly simple Saturday, August 11, 12
  • 99. Q&A Slides and code will be available on my blog: http://www.subfurther.com/blog http://www.slideshare.net/invalidname @invalidname Saturday, August 11, 12