Cocoaheads - Streaming on iOS devices

Preview:

DESCRIPTION

 

Citation preview

Streaming Video in iOS

Nirbhay K

http://above-inc.com

CocoaHeads - Cocoa on the Brain

Streaming Apps Overview

CNBC Pro Netflix Hulu +

Twitch.tvUstream.tvJustin.tv

Technology

• HLS (HTTP Live Streaming) - [Apple Inc.]• Progressive Download• Streaming on Other Platforms– Smooth Streaming - [Microsoft]– HDS (HTTP Dynamic Streaming) - [Adobe]– RTMP (Real Time Messaging Protocol) – [Adobe]– RTP (Real Time Transport Protocol)– RTCP (RTP Control Protocol)– RTSP (Real Time Streaming Protocol) = RTP+RTCP

MPEG–DASH HTTP Streaming Standard

DASH - Dynamic Adaptive Streaming over HTTP .

Courtesy - http://xkcd.com/927/

Problems with streaming on iOS

• Network • Do’s/Don’ts [Apple restrictions]

MEH.. !!

How do I get my streaming app working??

Todays menu

• Streaming Live v/s Streaming On Demand• How HLS works• Setting up HLS on Server• Streaming HLS in iOS• Using Wowza Server to deliver multi device

streaming

HLS Architecture

• Server components

• Distribution components

• Client components

HLS Architecture

• Server Components– Media Encoder

– Stream Segmenter• Media Segment File

• Index Files (m3u8 playlists)

– File Segmenter

HLS Architecture

• Distribution Components

File Ext. Mime Type

.m3u8 application/x-mpegURL or vnd.apple.mpegURL

.ts Video/MP2T

HLS Architecture

• Client components

– End user media player software

– Custom player

– HTML5 Browser

HLS Architecture

#EXTM3U#EXT-X-TARGETDURATION:10#EXT-X-VERSION:3#EXT-X-MEDIA-SEQUENCE:0#EXT-X-PLAYLIST-TYPE:VOD#EXTINF:10.00000,fileSequence0.ts#EXTINF:10.00000,fileSequence1.ts#EXTINF:10.00000, […]#EXT-X-ENDLIST

• Simple Index File (m3u8)

HLS Architecture

• Simple Index File (m3u8)

M3U8 fomat,Just a list of files to play

#EXTM3U#EXT-X-TARGETDURATION:10#EXT-X-VERSION:3#EXT-X-MEDIA-SEQUENCE:0#EXT-X-PLAYLIST-TYPE:VOD#EXTINF:10.00000,fileSequence0.ts#EXTINF:10.00000,fileSequence1.ts#EXTINF:10.00000, […]#EXT-X-ENDLIST

HLS Architecture

• Simple Index File (m3u8)

M3U8 fomat,Just a list of files to play

Metadata tags describing the content

#EXTM3U#EXT-X-TARGETDURATION:10#EXT-X-VERSION:3#EXT-X-MEDIA-SEQUENCE:0#EXT-X-PLAYLIST-TYPE:VOD#EXTINF:10.00000,fileSequence0.ts#EXTINF:10.00000,fileSequence1.ts#EXTINF:10.00000, […]#EXT-X-ENDLIST

Each segment file preceded by metadata eg.#EXTINF:10 (depicts segment duration)

HLS Architecture

• Simple Index File (m3u8)

M3U8 fomat,Just a list of files to play

Metadata tags describing the content

#EXTM3U#EXT-X-TARGETDURATION:10#EXT-X-VERSION:3#EXT-X-MEDIA-SEQUENCE:0#EXT-X-PLAYLIST-TYPE:VOD#EXTINF:10.00000,fileSequence0.ts#EXTINF:10.00000,fileSequence1.ts#EXTINF:10.00000, […]#EXT-X-ENDLIST

If there is no end tag client will treat this as live stream

Each segment file preceded by metadata eg.#EXTINF:10 (depicts segment duration)

HLS Architecture

• Simple Index File (m3u8)

M3U8 fomat,Just a list of files to play

Metadata tags describing the content

#EXTM3U#EXT-X-TARGETDURATION:10#EXT-X-VERSION:3#EXT-X-MEDIA-SEQUENCE:0#EXT-X-PLAYLIST-TYPE:VOD#EXTINF:10.00000,fileSequence0.ts#EXTINF:10.00000,fileSequence1.ts#EXTINF:10.00000, […]#EXT-X-ENDLIST

HLS ArchitectureBasic Configuration Diagram

Courtesy - http://apple.com/

HLS Specification

HTTP Live Streaming Specification

TOOLS• Media segmenter– File Segmenter

– Stream segmenter (Will not cover it today)

• Streaming Tools – Download link

mediafilesegmenter -f <foldername> <source file>.mp4

mediastreamsegmenter -s 3 -D -f <foldername> <live encoder url>

Setting up HLS with Tools

File Segmenter

{ Demo }

Distributing HLS with Webservers

• Apache • Nginx• Any webserver/CDN

{ Demo }

What is Wowza Server

Wowza Media Systems® provides the next

generation of media streaming software which

simplifies the highest quality live and on-

demand video streaming to any Internet-

connected device.

Why Wowza• Integrated Live Transcoder

• Multi protocol nDVR

• Multi Platform DRM

• Streaming to multiple devices including IPTV devices

• Restreaming of IP cameras or other sources

• Encoder for SHOUTcast / ICEcast restreaming

• Supports all major server OS

• Recording of live streams

• Multiparty video conferencing

• 10GBps per server performance

Life Before Wowza

Courtesy - http://www.telestream.net/

Wowza Live Stream delivery Diagram

Courtesy - http://www.wowza.com/

Setting up Wowza Server

{ Demo }

Live cam publishing on Wowza

{ Demo }

Consume Wowza stream

{ Demo }

Code Links

• iOS HLS Client– https://github.com/NirbhayK/Streamingplayer

• Factime camera broadcast using VLC (script)– https://github.com/NirbhayK/vlcbroadcastscript

Q&A

Recommended