+ All Categories
Home > Technology > JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Date post: 13-Aug-2015
Category:
Upload: guillaume-marty
View: 475 times
Download: 0 times
Share this document with a friend
52
Playing DVD in JavaScript
Transcript
Page 1: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

PlayingDVDin

JavaScript

Page 2: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

@g_marty guy living in London,

Working at on

Page 3: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

I have DVDs

Page 4: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

I use Google Play Music

Page 5: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

I love JavaScript

Page 6: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

I want Google Play Music for DVDsA service that streams my DVDs

from the cloudto my (mobile) browser

Page 7: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

But why?!!!1!1!ONEQ: Y U NO Netflix?

A: Not interesting for me.Q: Y U NO rip the video?

A: DVDs are more than just video.

Page 8: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

I implemented this in JavaScriptbut faced problems

Page 9: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

The structureDVD = Digital Versatile Disc

Page 10: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

The DVD specs...... is a paying document,

but was reverse engineered from discs

Page 11: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Files organisation2 folders:

AUDIO_TS/ (optional)VIDEO_TS/

Page 12: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

File typesInfo files (*.IFO, *.BUP)Video files (*.VOB)

Page 13: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

IFO filesPlayback logicChaptersLanguages available

Page 14: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

VOB filesVideo / AudioSubtitlesMenu UI

Page 15: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

DVD Virtual Machine16 general parameter registers (≈ variables)24 system parameter registers (language,region...)36 commands (jump, compare, set, goto...)

Page 16: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Example of command30 25 00 0A 00 03 01 02

If (GPRM1 == GPRM2) JumpVTS_PTT (PTT:10, VTS:3)

30 25 00 0A 00 03 01 02JumpVTS_PTT 10 (PTT) == 3 (VTS) 1 (GPRM1) 2 (GPRM2)if (gprm[1] === gprm[2]) { dvd.playTitle(3); dvd.playChapter(10);}

Page 17: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Playing DVDon the fly

Page 18: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

libdvdreadlibdvdnav

Page 19: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Experiment 1The browser reads the disc directly

Page 20: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Direct disc reading

Page 21: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Parsing IFO filesTyped arraysDataView

Page 22: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Playing VOB filesProblems occur

Page 23: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Browsers can't play the codecsMpeg 2AAC

Page 24: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Browsers can't handle huge filesVOB files can be as big as 1 Gb

Page 25: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Experiment 2Encode video on demand

Page 26: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Server in Node.js

Page 27: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

That doesn't workPlayback is jerky

Page 28: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Experiment 3Encode video beforehand to webm

Page 29: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Preencoded video

Page 30: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

This kind of works, but...

Page 31: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Server / client out of syncNeeds a powerful configuration

Page 32: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

But most of allthis isn't the web

Page 33: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Reintroducing theweb

Page 34: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Using a converter

Page 35: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Advantages

Page 36: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Host it yourselfVideos take a lot of server spaceStatic server runs on low-end hardware

Page 37: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Mobile friendly

Page 38: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Demo: Sita Sings the BluesDVD

A movie by Nina Paley published underthe Creative Commons license

Page 39: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty
Page 40: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

How?DVD feature Web platform

VOB files (video) <video>VOB files (subtitles) <track> & WebVTT

Multi-angle and multi-audio MediaControllerChapters <track kind="chapters">

Menu buttons <button> & PNGDVD VM JavaScript

Page 41: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

DVD converter1. IFO files are parsed to JSON2. Chapters are generated as WebVTT3. NAV packets are extracted to JSON4. The buttons size/position are saved to CSS5. The menu still frames are saved to PNG6. VM commands are compiled into JavaScript7. The video is encoded to Webm

Page 42: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Playback<x-video> a video player on steroids

github.com/gmarty/x-video

Page 43: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Lessons learnedBrowsers can't play DVD on the fly

Page 44: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

but the web platform is powerful

Page 45: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

JavaScript handles formatsMP3PDFFlashnow DVD!

Page 46: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

the web is versatile

Page 47: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

the web can give a 2nd life to old formats

Page 48: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Where's the code?github.com/gmarty/DVD.js

Page 49: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

What's next?

Page 50: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

BonusShow me the code

Page 51: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty
Page 52: JS Conf 2014 - Playing DVD in JavaScript for the sake of interoperability - Guillaume Marty

Guillaume C. Marty @g_marty gmarty


Recommended