Top Banner
Adaptive Video Transmuxing Donato Borrello @CodeAssault Lead Engineer, JW Player The Nitty Gritty of In JavaScript
32

Nitty Gritty of Adaptive Video Transmuxing in JS

Jan 22, 2018

Download

Software

Donato Borrello
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Nitty Gritty of Adaptive Video Transmuxing in JS

Adaptive Video Transmuxing

Donato Borrello@CodeAssault

Lead Engineer, JW Player

The Nitty Gritty of

In JavaScript

Page 2: Nitty Gritty of Adaptive Video Transmuxing in JS

Take MPEG-TS and make it MP4

Page 3: Nitty Gritty of Adaptive Video Transmuxing in JS

What’s goin’ on wit client-side video

Like this ------------>

Page 4: Nitty Gritty of Adaptive Video Transmuxing in JS

A 10,000 foot view

Page 5: Nitty Gritty of Adaptive Video Transmuxing in JS

What’s a Provider?

Page 6: Nitty Gritty of Adaptive Video Transmuxing in JS

Why HTTP Live Streaming?

HLS is the most widely used ABR streaming format

Page 7: Nitty Gritty of Adaptive Video Transmuxing in JS

Research

Page 8: Nitty Gritty of Adaptive Video Transmuxing in JS

Take it? or Make it?

Page 9: Nitty Gritty of Adaptive Video Transmuxing in JS

Opportunities for improvement

➔ Faster time to first frame

◆ Incremental transmuxing instead of batch

◆ “Jump-start” downloads

◆ Clever Parsing using FSM

➔ More feature-rich

◆ Multi-track audio (HLSv4)

➔ More streams supported

◆ A frustratingly thorough test suite

Ultimately, we can take the best parts from each

Page 10: Nitty Gritty of Adaptive Video Transmuxing in JS

Caterpillar is born!

Page 11: Nitty Gritty of Adaptive Video Transmuxing in JS

Caterpillar Shaped Architecture!

Adaptive Video Streaming over HTTP

Page 12: Nitty Gritty of Adaptive Video Transmuxing in JS

Transmuxing with Incremental Computation

Page 13: Nitty Gritty of Adaptive Video Transmuxing in JS
Page 14: Nitty Gritty of Adaptive Video Transmuxing in JS
Page 15: Nitty Gritty of Adaptive Video Transmuxing in JS

Transmuxing Engine

Page 16: Nitty Gritty of Adaptive Video Transmuxing in JS

Events or FRP

➔ RxJS using Observable objects

➔ Event based stream philosophy (push streams)

◆ Equates to batch processing

➔ We want Pull Streams

◆ Backpressure with buffers

➔ Quite complex - unused features and hard to debug

➔ Profiling was challenging - trampoline what?

Page 17: Nitty Gritty of Adaptive Video Transmuxing in JS

Communicating Sequential Processes

➔ Enter CSP

◆ Channels, processes and buffers

◆ Using generators

➔ Does exactly as much work as needed

➔ Cleaner code

◆ Easier profiling and debugging

Process ChannelChannel

Page 18: Nitty Gritty of Adaptive Video Transmuxing in JS

“Jump-start” Downloading

Page 19: Nitty Gritty of Adaptive Video Transmuxing in JS
Page 20: Nitty Gritty of Adaptive Video Transmuxing in JS

A 10,793 Line Media Manifest

248 kb file size

At 1 Mbps, that’s 250ms of

added latency until download

completes

Page 21: Nitty Gritty of Adaptive Video Transmuxing in JS

Manifest Parsing

➔ There is a big async dependency

Page 22: Nitty Gritty of Adaptive Video Transmuxing in JS

More typical examples

DVR Streams - worst offenders

Live Streams - rarely a problem

VOD Streams - longer movies see

improvement

The media playlist for Captain

America - Winter Soldier is

1500 lines, 27kb

Page 23: Nitty Gritty of Adaptive Video Transmuxing in JS

NALU Parsing with Finite State Machines

Page 24: Nitty Gritty of Adaptive Video Transmuxing in JS

PES > NALU > H264 > MP4

Page 25: Nitty Gritty of Adaptive Video Transmuxing in JS

That extra step for video PES Packets

Page 26: Nitty Gritty of Adaptive Video Transmuxing in JS

I Started Dreaming in Hex

TS Packet Starts

0x47

PES Packet

Starts

NALU starts

0x000001

Page 27: Nitty Gritty of Adaptive Video Transmuxing in JS

Finding NAL Units

They don’t line up with anything.

They can start and end anywhere.

All we know is 0x001 or 0x0001

Page 28: Nitty Gritty of Adaptive Video Transmuxing in JS
Page 29: Nitty Gritty of Adaptive Video Transmuxing in JS

Miscellanea

Page 30: Nitty Gritty of Adaptive Video Transmuxing in JS

Adaptive Switching

➔ Time to download

➔ Time to Transmux

➔ Network Volatility

➔ Manifest accuracy

➔ Available Qualities

➔ Individual stream status

Page 31: Nitty Gritty of Adaptive Video Transmuxing in JS

➔ Generators screwed us (blame v8)

◆ Babel-Regenerator saved us

➔ UglifyJS is only partially compatible with ES6

➔ Webpack + Babel + Typescript was a hassle

Impact of using ES6

Page 32: Nitty Gritty of Adaptive Video Transmuxing in JS

Thanks!

@JWDevelopers

Rob Walch

Kyle Aurand

Jong Park

Evol Greaves

Danny Finkelstein

Mohammed Siddique

Sid Patel

Eric Boyd

Andrew Prelusky

Pooja Maden

@Google

Joey Parrish

@Chromium

Chris Cunningham

Dale Curtis

@gliese1337/HLS.js

Logan Kearsley