31
Streaming Video in iOS Nirbhay K http://above-inc.com CocoaHeads - Cocoa on the Brain

Cocoaheads - Streaming on iOS devices

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Cocoaheads - Streaming on iOS devices

Streaming Video in iOS

Nirbhay K

http://above-inc.com

CocoaHeads - Cocoa on the Brain

Page 2: Cocoaheads - Streaming on iOS devices

Streaming Apps Overview

CNBC Pro Netflix Hulu +

Twitch.tvUstream.tvJustin.tv

Page 3: Cocoaheads - Streaming on iOS devices

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

Page 4: Cocoaheads - Streaming on iOS devices

MPEG–DASH HTTP Streaming Standard

DASH - Dynamic Adaptive Streaming over HTTP .

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

Page 5: Cocoaheads - Streaming on iOS devices

Problems with streaming on iOS

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

Page 6: Cocoaheads - Streaming on iOS devices

MEH.. !!

How do I get my streaming app working??

Page 7: Cocoaheads - Streaming on iOS devices

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

Page 8: Cocoaheads - Streaming on iOS devices

HLS Architecture

• Server components

• Distribution components

• Client components

Page 9: Cocoaheads - Streaming on iOS devices

HLS Architecture

• Server Components– Media Encoder

– Stream Segmenter• Media Segment File

• Index Files (m3u8 playlists)

– File Segmenter

Page 10: Cocoaheads - Streaming on iOS devices

HLS Architecture

• Distribution Components

File Ext. Mime Type

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

.ts Video/MP2T

Page 11: Cocoaheads - Streaming on iOS devices

HLS Architecture

• Client components

– End user media player software

– Custom player

– HTML5 Browser

Page 12: Cocoaheads - Streaming on iOS devices

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)

Page 13: Cocoaheads - Streaming on iOS devices

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

Page 14: Cocoaheads - Streaming on iOS devices

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

Page 15: Cocoaheads - Streaming on iOS devices

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

Page 16: Cocoaheads - Streaming on iOS devices

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

Page 17: Cocoaheads - Streaming on iOS devices

HLS ArchitectureBasic Configuration Diagram

Courtesy - http://apple.com/

Page 18: Cocoaheads - Streaming on iOS devices

HLS Specification

HTTP Live Streaming Specification

Page 19: Cocoaheads - Streaming on iOS devices

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>

Page 20: Cocoaheads - Streaming on iOS devices

Setting up HLS with Tools

Page 21: Cocoaheads - Streaming on iOS devices

File Segmenter

{ Demo }

Page 22: Cocoaheads - Streaming on iOS devices

Distributing HLS with Webservers

• Apache • Nginx• Any webserver/CDN

{ Demo }

Page 23: Cocoaheads - Streaming on iOS devices

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.

Page 24: Cocoaheads - Streaming on iOS devices

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

Page 25: Cocoaheads - Streaming on iOS devices

Life Before Wowza

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

Page 26: Cocoaheads - Streaming on iOS devices

Wowza Live Stream delivery Diagram

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

Page 27: Cocoaheads - Streaming on iOS devices

Setting up Wowza Server

{ Demo }

Page 28: Cocoaheads - Streaming on iOS devices

Live cam publishing on Wowza

{ Demo }

Page 29: Cocoaheads - Streaming on iOS devices

Consume Wowza stream

{ Demo }

Page 30: Cocoaheads - Streaming on iOS devices

Code Links

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

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

Page 31: Cocoaheads - Streaming on iOS devices

Q&A