wksp07: media processing workflow

68
Media Processing Workflow Alex Zambelli Media Technology Evangelist Developer & Platform Evangelism [email protected]

Upload: technical-dude

Post on 17-May-2015

1.967 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WKSP07: Media Processing Workflow

Media Processing Workflow

Alex ZambelliMedia Technology EvangelistDeveloper & Platform [email protected]

Page 2: WKSP07: Media Processing Workflow

Workshop Overview

• Silverlight media capabilities• Smooth Streaming 101– 15 min break

• Live Smooth Streaming• Workflow and architecture– 15 min break

• Encoding for Smooth Streaming

Page 3: WKSP07: Media Processing Workflow

A Brave New World

• Encoding 320x240 video on a laptop is “so 2002”

• HTTP adaptive streaming has entirely changed the game in the past 2 years

• The future for Silverlight is all Smooth Streaming, all HD

• Video quality is better than ever, but at the price of complexity and bandwidth

• Don’t worry, it only gets easier from here

Page 4: WKSP07: Media Processing Workflow

Silverlight Media Formats

• Windows Media– ASF file format (*.asf, *.wmv, *.wma)– VC-1 (WMV9), WMV8, WMV7 video codecs– WMA Pro, WMA Standard, MP3 audio codecs

• MPEG-4– MP4 file format (*.mp4, *.3gp, *.mov)– H.264 video codec (Baseline, Main, High profiles)– AAC audio codec (AAC-LC profile)

Page 5: WKSP07: Media Processing Workflow

Silverlight Media Extensibility

• Smooth Streaming– VC-1 and H.264 video– WMA Pro, WMA Standard and AAC-LC audio– Supported via Smooth Streaming Media Element

extension

• MediaStreamSource lets developers add support for 3rd party codecs, formats and delivery methods

Page 6: WKSP07: Media Processing Workflow

Silverlight Media Protection

• Silverlight DRM, powered by PlayReady– PlayReady AES-256 encryption– Windows Media DRM encryption

• Silverlight 3– VC-1 and WMA encryption only– Live DRM (Direct License Acquisition) only

• Silverlight 4– H.264 and AAC encryption– Offline DRM

Page 7: WKSP07: Media Processing Workflow

Silverlight Media Delivery

• Windows Media Services streaming– Windows Server 2008 and 2003• Unicast (WMS HTTP)• Multicast

• HTTP progressive download– Any HTTP 1.0/1.1 web server

• IIS Smooth Streaming– Windows Server 2008 (IIS7)

Page 8: WKSP07: Media Processing Workflow

Silverlight Media Framework

• No need to reinvent the wheel every time a Silverlight video player is needed

• Silverlight Media Framework: http://smf.codeplex.com

• All essential playback features plus advanced Smooth Streaming features– DVR, Fast Forward, Rewind, Replay, Slow Motion– Markers, captions, dynamic ad insertion– Rich analytics and logging

Page 9: WKSP07: Media Processing Workflow

Media Delivery Methods

• Unicast– Traditional Streaming– Progressive Download– HTTP-based Adaptive Streaming

• Multicast– IP Multicast

Page 10: WKSP07: Media Processing Workflow

Unicast

Origin Server

Many one-to-one streamsRequires more bandwidth per userMay require more serversFor private and public networks

Page 11: WKSP07: Media Processing Workflow

Multicast

Origin Server

A single one-to-many streamUses bandwidth of only one streamRequires multicast-enabled networksTypically requires fewer servers

Page 12: WKSP07: Media Processing Workflow

Movie

Unicast Methods

Packet Packet Packet Packet Packet

Traditional Streaming

HTTP Adaptive Streaming

Movie

Progressive Download

Play SeekPaus

e

Video @ 01:04?Video @ 01:06?

Video @ 01:08?

Page 13: WKSP07: Media Processing Workflow

Internet Streaming Challenge

• Traditional streaming designed for efficient media delivery

• Works well in small networks but on the Internet suffers from serious drawbacks:– Doesn’t scale to today’s Internet audience– Doesn’t take into account today’s Internet

structure and organization– Designed for network conditions less volatile than

Internet traffic

Page 14: WKSP07: Media Processing Workflow

HTTP Adaptive Streaming

• Hybrid media delivery method – Acts like streaming but is in fact a series of short progressive

downloads– Video and audio delivered as series of small files over HTTP

• Built for the Web– Leverages existing HTTP caches– Scales exceptionally well to meet high demand

• Resilient to network unpredictability– Client can seamlessly switch video quality and bit rate based on

perceived network bandwidth and CPU resources

• Applicable to both on-demand and live delivery

Page 15: WKSP07: Media Processing Workflow

Windows Server Media Delivery

IIS Media Services

• Traditional Streaming• Unicast• WMS RTSP• WMS HTTP

• Multicast• WMS Multicast

• Progressive Download• Bit Rate Throttling

• HTTP Adaptive Streaming• Smooth Streaming

Page 16: WKSP07: Media Processing Workflow

Smooth Streaming

• Smooth Streaming– Microsoft implementation of HTTP-based adaptive

streaming– Best of both worlds

• Responsive and efficient like streaming• Cheap and scalable like progressive download

– Superior user experience• No buffering, no stutter• Instant start, instant seek• Seamless bit rate switching based on bandwidth and CPU

Page 17: WKSP07: Media Processing Workflow

Multi Bit Rate Revisited

2.4 Mbps

1.5 Mbps

700 kbps

300 kbps

00:27.24 03:47.16 05:05.04 07:33.10

Page 18: WKSP07: Media Processing Workflow

Adapting Bit Rate in Real-Time

2.4M

300K

Bit Rate Heuristics

300K @ 00:00?700K @ 00:02?

2.4M @ 00:04?1.5M @ 00:06?

2.4M @ 00:08?

00:00 00:02 00:04 00:06 00:08300K (start quickly)

700K (good network)2.4M (great network)

1.5M (glitch)2.4M (play on…)

Page 19: WKSP07: Media Processing Workflow

Smooth Streaming Design

• Smooth Streaming File Format based on MP4 (ISO Base Media File Format)

• Video is encoded and stored on disk as one contiguous MP4 file– One file per bit rate

• Each video Group of Pictures (GOP) is stored in a separate Movie Fragment box– This allows accurate fragmentation at key frames

• Contiguous file is virtually split up into chunks when responding to a client request

Page 20: WKSP07: Media Processing Workflow

Smooth Streaming File FormatFi

le T

ype (ftyp)

Movie Metadata (moov)

Movie Header(mvhd)

Track (trak)

• Track Header (tkhd)

• Media (mdia)

Movie Extends (mvex)

•Movie Extends Header (mehd)

•Track Extends (trex)

Fragment

Med

ia D

ata

(mda

t)

Movie Fragment (moof)

Mov

ie F

ragm

ent H

eade

r (m

fhd)

Trac

k Fr

agm

ent

(traf)

Fragment

Med

ia D

ata

(mda

t)

Movie Fragment (moof)

Mov

ie F

ragm

ent H

eade

r (m

fhd)

Trac

k Fr

agm

ent

(traf)

Movie Fragment Random Access (mfra)

Trac

k Fr

agm

ent R

ando

m A

cces

s

(tfra

)

Mov

ie F

ragm

ent R

ando

m A

cces

s O

ffset

(m

fro)

Page 21: WKSP07: Media Processing Workflow

On-Demand Presentations

• MP4 files containing video/audio/data fragments– New file extensions instead of *.mp4– *.ismv for files containing video and audio tracks, or only video tracks– *.isma for files containing only audio tracks

• On-demand server manifest file– File extension: *.ism– Describes the relationships between media tracks, bitrates and files on disk– Uses SMIL 2.0 XML format

• Client manifest file– File extension: *.ismc– Describes available streams, codecs, bitrates, resolutions, metadata– Uses XML format

Page 22: WKSP07: Media Processing Workflow

On Demand Server Manifest

Page 23: WKSP07: Media Processing Workflow

On Demand Client Manifest

Page 24: WKSP07: Media Processing Workflow

Client-Server Communication

• All requests to the server are formed as RESTful URLs• Client always first requests the client manifest:

http://iis.net/video.ism/Manifest

• After parsing the manifest the client begins making requests for fragments by indicating bit rates and offset times it learned from the manifest:http://iis.net/video.ism/QualityLevels(350000)/Fragments(video=40040000) http://iis.net/video.ism/QualityLevels(48000)/Fragments(audio=62293333)

• Every valid HTTP request returns a file of MIME type “video/mp4”

Page 25: WKSP07: Media Processing Workflow

Serving Fragments On Demand

• IIS7 Smooth Streaming handler interprets the RESTful URL request

• It maps the quality level to a physical ISMV file based on the server manifest (*.ism) and calculates the fragment location within the contiguous ISMV file based on the time offset

• Because the wire format (fragment) is just a subset of the disk format (MP4), the extraction process is simple– No re-muxing necessary

• Dynamic stream switching logic is fully implemented in Silverlight application code – no server-side detection

Page 26: WKSP07: Media Processing Workflow

Demo

• DEMO:• Setting up On Demand publishing points• Using Fiddler to monitor Smooth Streaming

traffic

Page 27: WKSP07: Media Processing Workflow

Live Smooth Streaming

• Live publishing point identified by *.isml extension

• Client-server communication very similar to on-demand

• Server continually appends MP4 file with new fragments from encoder and makes them available to client– This allows DVR-like seeking within the existing

archive

Page 28: WKSP07: Media Processing Workflow

Encoder-Server Communication

• Encoder pushes fragmented MP4 stream to server in body of a long-running HTTP POST requesthttp://iis.net/live.isml/stream(720p)

• Encoder inserts Live Server Manifest Box into start of MP4 stream– Contains a SMIL-formatted Live Server Manifest

very similar to On-Demand Manifest– Describes all tracks in that encoder’s stream

Page 29: WKSP07: Media Processing Workflow

Encoder-Server Communication

• Each sent fragment contains a box with absolute time and duration

• Timestamps are typically derived from the input source Linear Time Code (LTC)

• If multiple encoders are used to encode the same video source, it’s essential that a time code generator is used to keep their LTC in sync

Page 30: WKSP07: Media Processing Workflow

Serving Live Fragments

• Server parses the encoder manifests and starts collecting MP4 fragments

• Server builds a cumulative runtime index in memory for all incoming fragments

• Server stores fragments into a temporary DVR ISMV or a permanent ISMV archive– When the pub point is shut down, server

generates ‘mfra’ index box for ISMV archive

Page 31: WKSP07: Media Processing Workflow

Live Client Workflow

• Client requests the latest manifest http://iis.net/live.isml/Manifest

• Server adds up all the encoder manifests and the runtime fragment index and sends the latest version to the client

• Every fragment contains information about the next fragment

• No need to repeatedly download manifest– Client builds its own cumulative runtime index based on

the lookahead info in the fragments

Page 32: WKSP07: Media Processing Workflow

Demo

• DEMO:• Basic Live Smooth Streaming workflow

Page 33: WKSP07: Media Processing Workflow

Live Smooth Publishing Points

• ISML files are SMIL 2.0 formatted XML configuration files

• Live publishing points can be created via the IIS Manager UI or by manually creating ISML files on server

• Both push and pull publishing models are supported– Live publishing points can also push to and pull

from other live publishing points

Page 34: WKSP07: Media Processing Workflow

Live Publishing Point – IIS Mgr

Page 35: WKSP07: Media Processing Workflow

Live Publishing Point - ISML

Page 36: WKSP07: Media Processing Workflow

ISML Syntax

• sourceType– Push: source streams will be pushed to pub point– Pull: pub point will pull streams from listed URLs

• publishing– Streams: pub point can serve streams to other live pub points– Fragments: clients can request fragments– Archives: archiving is enabled

• lookaheadChunks: number of fragments server will buffer before making them available to clients

• manifestWindowLength: length of DVR moving window• archivePath: local path where archives will be written

Page 37: WKSP07: Media Processing Workflow

Ingest ServerOrigin Server:Realtime Stream

Ingests and Origins

Encoder8 Mbps

Origin Server:Delayed Stream

Origin Server:VOD Archive

Origin Server:Realtime Stream

Origin Server:Delayed Stream

Origin Server:VOD Archive

Page 38: WKSP07: Media Processing Workflow

DEMO

• DEMO:• Advanced Live Smooth Streaming workflow

Page 39: WKSP07: Media Processing Workflow

Network Design Considerations

• Bandwidth, bandwidth, bandwidth

Encoder egress bit rate =(All video and audio bit rates together)

x(Number of ingest publishing points)

• Leave enough headroom for bit rate spikes and bursts– Play it: leave 50%-100% headroom

Page 40: WKSP07: Media Processing Workflow

Building Smooth Streaming Origins

• Network– Make sure NICs can handle the cumulative ingress

and egress bandwidth• CPU and memory– Follow typical server configuration guidelines

• Disk– Live Smooth Streaming can require high

read/write rates– 10,000 RPM disks are a good idea

Page 41: WKSP07: Media Processing Workflow

Redundancy and Failover

• Encoders– Active-active redundant encoder configuration not

supported– Encoder hot swap is possible as long as encoder

doesn’t signal end-of-stream to server– Configurable time-out periods can help survive

temporary loss of network connectivity – Some encoders support pushing to multiple

publishing points concurrently, while others do pub point roll over in case of failure

Page 42: WKSP07: Media Processing Workflow

Redundancy and Failover

• Servers– IIS is designed to discard duplicate fragments– This allows ingest and origin servers to be set in

active-active configuration

Encoder

Ingest server:Primary

Ingest server:Secondary

Origin server

Page 43: WKSP07: Media Processing Workflow

Redundancy and Failover

• Origins– CDNs can dynamically change DNS to redirect

traffic to secondary origin when primary fails

Encoder

Ingest server:Primary

Ingest server:Secondary

Origin server:Primary

Origin server:Secondary

DNS

Page 44: WKSP07: Media Processing Workflow

Video Encoding

Page 45: WKSP07: Media Processing Workflow

Smooth Streaming Encoders

• Many vendors to choose from:– Anystream (Grab Networks)– Digital Rapids– Envivio– Inlet Technologies– Microsoft– Rhozet (Harmonic)– Telestream– VBrick– ViewCast– Winnov

Page 46: WKSP07: Media Processing Workflow

H.264 or VC-1?

• Customers should choose whichever codec best fits their encoding workflow and meets their quality requirements

• However, keep in mind:– H.264 decoding is typically more CPU intensive than VC-1 decoding

for the same resolution and frame rate– In Silverlight 3: H.264 decoding requires about 15-25% more CPU

time than VC-1 decoding with similar content properties

• Good rule of thumb (for now):– For HD video, use VC-1 to reach largest audience– For SD video and smaller, use H.264 if quality gains are noticeable

Page 47: WKSP07: Media Processing Workflow

Encoding for Smooth Streaming

• Use VC-1 Advanced Profile or H.264 Main/High Profile• 2 second key frame distance works very well

– Must be closed GOP– Client heuristics work best with fixed length (non-adaptive) GOP

• Set video buffer size to 2x-3x key frame distance• Use WMA Professional audio codec for best quality at low

bitrates– Comparable to HE-AAC – excellent stereo quality even at 48 kbps

• Client heuristics are currently tuned for CBR content, so if using VBR set the peak bit rate within 15% of average bit rate for best playback

Page 48: WKSP07: Media Processing Workflow

Multi Bit Rate Encoding Revisited

2.5 Mbps

1.5 Mbps

750 kbps

350 kbps

00:27.24 03:47.16 05:05.04 07:33.10

Page 49: WKSP07: Media Processing Workflow

Variable Resolution

• Why do we vary encoded resolution together with bit rate?

• Encoding the same resolution at inappropriately low bit rates introduces objectionable compression side effects into the video: blockiness, twirling details, color smearing, etc.

• By lowering the resolution proportionally to the bit rate we maintain a consistent level of compression quality in exchange for giving up some visual detail

• It’s a compromise: between two evils, customers prefer a blurry picture over a blocky picture

Page 50: WKSP07: Media Processing Workflow

VC-1: 640x360 at 1250 kbps

Page 51: WKSP07: Media Processing Workflow

VC-1: 640x360 at 300 kbps

Page 52: WKSP07: Media Processing Workflow

VC-1: 288x160 at 300 kbps

Page 53: WKSP07: Media Processing Workflow

How Many Bit Rates Do I Need?

• You can use as few as you’d like – even just a single bit rate

• Upper bound is typically set by the encoder– Anything more than 12 video bit rates is probably

overkill• 4 video bit rates for SD and 6 bit rates for 720p

HD are good starting points• Silverlight client currently only supports 1

audio bit rate

Page 54: WKSP07: Media Processing Workflow

Choosing the Quality Levels

• Smooth Streaming Multi Bit Rate Calculator

http://alexzambelli.com/WMV/MBRCalc.html

Page 55: WKSP07: Media Processing Workflow

Choosing the Quality Levels

• Recommended minimum quality level:320x176 at 350 kbps

• Never set the minimum quality level below 288x160 or 300 kbps– Small video = Bad full screen experience

• Compression is most efficient when width and height are multiples of 16

• One of the resolutions should match the player video window size

Page 56: WKSP07: Media Processing Workflow

NBC Sunday Night Football

Video Bit Rate Width Height FPS

3450 1280 720 29.97

2250 960 540 29.97

1500 720 404 29.97

950 544 304 29.97

600 400 224 29.97

350 288 160 29.97

Video:VC-1 Advanced Profile

Audio:WMA 10 Professional48 kbps 48 kHz 16-bit stereo

Page 57: WKSP07: Media Processing Workflow

Configuring Live Encoders

• Live encoders have finite CPU resources• Higher resolution = More CPU cycles• Overloading a live video encoder will cause

poor image quality and dropped frames• Most live encoders are bound by number of

CPU cores

Page 58: WKSP07: Media Processing Workflow

Configuring Live Encoders

• Good rule of thumb for live VC-1 encoding:For each resolution you’d like to use, count the number of CPU cores needed per this table:

• If total number of needed cores exceeds the number of CPU cores in your encoder, reduce the number of quality levels until they fit

Min Resolution Max Resolution CPU Cores Required

16x16 512x288 1

544x304 704x400 2

736x416 1280x720 4

Page 59: WKSP07: Media Processing Workflow

Distributed Live Encoding

• Some live encoders (Inlet Spinnaker) support distributing bit rates of the same video across multiple encoders– Muse use LTC time code generator for sync

• Always attach audio stream to the video stream with lowest bit rate

• Make sure encoder load is distributed evenly between encoders– Balance based on pixel count

Page 60: WKSP07: Media Processing Workflow

CBS March Madness

Encoder A Encoder B

288x160 + audio 400x224

800x448 544x304

960x540 1280x720

Video Bit Rate Width Height FPS

3450 1280 720 29.97

2400 960 540 29.97

1800 800 448 29.97

1050 544 304 29.97

650 400 224 29.97

350 288 160 29.97

Page 61: WKSP07: Media Processing Workflow

Live Encoding Tips & Tricks

• Most live Smooth Streaming encoders can’t handle above 720p

• If source is 720p50 or 720p59.94, don’t forget to set frame rate to half

• If source is 1080i, it’s faster to do single field resizing (bobbing) instead of full frame deinterlacing

• If source is 480i or 576i, use full frame deinterlacing, preferably motion adaptive

• Super Sampling scaling gives best quality• Denoising filters can improve compressed quality

Page 62: WKSP07: Media Processing Workflow

Expression Encoder 3: Smooth VC-1

• Required Settings:– Profile: VC-1 Advanced Profile– Adaptive GOP: Disabled– Closed GOP: Enabled– Output Mode: Elementary Stream

Sequence Header– Create separate file per stream:

Enabled

• Recommended Settings:– Resize Mode: Stretch– Adaptive Dead Zone: Conservative– In-Loop: Enabled– Overlap: Enabled– B-Frame Number: 1– Search Range: Adaptive

Page 63: WKSP07: Media Processing Workflow

Expression Encoder 3: Smooth H.264

• Required Settings:– Profile: H.264 Main or Baseline– Create separate file per stream:

Enabled

• Recommended Settings:– Profile: H.264 Main Profile– Resize Mode: Stretch– Number of Reference Frames: 4– B-Frame Number: 2– Search Range: 256– Entropy Mode: CABAC– In-Loop Filter: Enabled

Page 64: WKSP07: Media Processing Workflow

DEMO

• DEMO:• Configuring Inlet Spinnaker HD

Page 65: WKSP07: Media Processing Workflow

The More You Know…

• Related MIX10 Sessions:• Microsoft Silverlight "Media" : Moving at 60fps

– Tuesday 11:30 am• Introducing the Silverlight Rough Cut Editor

– Tuesday 1:30 pm• Smooth Streaming Live in HD: From Camera to Screen

– Tuesday 3:00 pm• Smooth Streaming Live in HD: 2010 Olympic Winter

Games– Tuesday 4:30 pm

Page 66: WKSP07: Media Processing Workflow

That’s All!

• Please fill out the evaluation forms!

• Enjoy MIX!

Page 67: WKSP07: Media Processing Workflow
Page 68: WKSP07: Media Processing Workflow

© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,

it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.