18
This Old Video Site: How PBS streams video - and you can too! Edgar Román PyCon 2013

Pycon2013

Embed Size (px)

Citation preview

Page 1: Pycon2013

This Old Video Site: How PBS streams video - and you can too!

Edgar RománPyCon 2013

Page 2: Pycon2013

PBS Digital

• We are the online division of the Public Broadcasting Service

• We stream millions videos for both pbs.org and pbskids.org• Our core projects and video CMS are python based

This talk focuses on streaming video, not pythonAnd streaming video in 2013…

Disclaimer: Reference herein to any specific commercial products, or services does not necessarily imply its endorsement, recommendation, or favoring by the Public Broadcasting Service

Page 3: Pycon2013

Online Video Goal

One of our goals at PBSd is to make PBS video accessible everywhere,

by everyone

This goal affects how we stream video, and your goals will affect how you stream online video

Page 4: Pycon2013

Video Formats

• 1994 - MPEG-2– Used by Digital Television and DVD– Lossless format, big files

• 2003 - MPEG-4 with H.264 (AVC)– MPEG-4 is the container format and H.264 is

the video codec– Lossy format, much smaller files– More complex to decode

• Ogg Vorbis/WebM VP8/Other– Now you’re in the niche video formats– Great if you can narrow your audience

Page 5: Pycon2013

MPEG-4 with H.264

• Success driven by broad support– Flash support since 9.115– SilverLight, Windows, Xbox, PS3, Android, iOS

• Excellent compression• Huge number of options

– Standard Profiles: Baseline vs Main vs High• But there is a shadow over H.264

– MPEG-LA licensing fees– ‘Free to end users’

Page 6: Pycon2013

Video Streaming

• HTTP– Good ol’ progressive download

• RTMP– Proprietary from Adobe

• HTTP Live Streaming (HLS)• Others

– RTSP– MS Smooth Streaming– HTTP Dynamic Streaming– DASH

Page 7: Pycon2013

Video Playback

• Player Requirements– Plays Ads– Closed Captioning Support– Customizable (Twitter, Facebook, Buy DVD /

iTunes)• Using combinations of many players

– Open Source Media Framework (OSMF)– Custom HTML5 framework– Native players on mobile devices

Page 8: Pycon2013

How to get started with video

• First Target: Desktop browsers– Picked MPEG4/H.264 to lower file size– MP4 main profile– Delivery via RTMP– Broad support in Flash players

– Started with 400Kbps in 2009– Expectation now is in range of 800Kbps to

1.2Mbps

Page 9: Pycon2013

S3Amazon

Cloudfront CDN

Includes Flash Media Server

MP4 Main Profile

Delivery Via RTMP

Page 10: Pycon2013

Mobile Devices

• Apple’s iOS– No Flash– HTTP Live Streaming (HLS)– Auto bitrate adjust possible– Any old CDN will do– Built-in player

• Android– MP4 Baseline via HTTP Progressive download– Later versions of Android support HLS

• Capability Detection on app servers

Page 11: Pycon2013

S3 Amazon Cloudfront CDN

Includes Flash Media Server for delivery via RTMP

Plain old CDN serving HTTP files

iPhone

iPhone

HLS Encoded

Page 12: Pycon2013

S3 Amazon Cloudfront CDN

Includes Flash Media Server for delivery via RTMP

Plain old CDN serving HTTP files

iPhone

iPhone

DroidMP4 Baseline

Page 13: Pycon2013

HTML5 <video> tag

• Allows browser to have native video support• Basic <video> tag is great, but lacks frills to match

rich Flash environment• HTML5 frameworks out there:

– VideoJS– MediaElement– JWPlayer

• If you need Flash-like flexibility in HTML5, be prepared for disappointment– Ad serving– Captions– Video Codec support

Page 14: Pycon2013

Transcoding

• Act of converting one video format to another• Useful Tools

• At PBS we start with a high-resolution 5 Mbps mp4 file

• From this we create 16 streamshttp://to.pbs.org/video-specs

Local Machine Online Servicesffmpeg zencoder

x264 Encoding.comHandbrake

Page 15: Pycon2013

Editor Uploads Mezzanine File with caption file

Store Original File in Archive and send to Transcoding Service

Stage files on CDN Origin Server and register streams in CMS

Django site determines client video capabilities and renders links

Page 16: Pycon2013

Haxors stealing my stuff

• Tough challenge – see ‘analog loophole’• PBS offers many videos for free streaming

online so motivation to steal is low• Your circumstances might be different• Beware the DRM Graveyard

– http://opensource.com/life/12/7/drm-graveyard-brief-history-digital-rights-management-video-film-and-tv

Page 17: Pycon2013

Questions

Page 18: Pycon2013

More Info

• Waggoner, Ben. Compression for Great Video and Audio. Focal Press. © 2010. 

• PBS Video Specs:http://to.pbs.org/video-specs

• https://github.com/pbs/pycaption

• This presentation available at:http://to.pbs.org/pycon2013