kontainer-js
Megro.es #3
Apr. 19th, 2016 at Drecom
Kuu Miyazaki
GitHub: @kuu
Twitter: @miyazaqui
kontainer-js > MP4 parser
● A parser/editor library written in ES2015
● Runs both on Node.js and in the browser
● Provides its API as JSX
MP4 > nested boxes
MP4 > nested boxes
ftyp moov mdat
mvhd trak
tkhd mdia
...
length type property
Nested boxes > DOM
DOM > React > JSX
Nested boxes
How about writing MP4 in JSX?
How about writing MP4 in JSX?
render() {
return (
<file>
<ftyp majorBrand="isom" />
<moov>
<mvhd creationTime={new Date()} timeScale={1} nextTrackId={4} />
<trak>
<tkhd {...{trackId: 1, width: this.width, height: this.height}} />
<mdia>
...innerElements
</mdia>
</trak>
</moov>
<mdat data={buffer} />
</file>
);
}
That’s what I built!
How kontainer-js works
{
type: ‘ftype’,
props : {
majorBrand: ‘isom’,
},
},
{
type: ‘moov’,
children: [
{
type: ‘mvhd’,
props: {
timeScale: 1,
…
},
]
}
parse
serialize
Byte stream
JS object
transpile
JSX
Development workflow
Lint ● eslint
Test ● [Browser] karma-jasmine + browserify(baberify)
● [Node] jasmine-es6
Build/Deploy ● [Browser] browserify(baberify) + uglify-js
● [Node] dist-es6
JSX Transpile ● Self-built Babel plugin (transform-kontainer-js)
Transpilation is slow
So, defer it as long as possible
Dev Machine
GitHub
npm
ES5
ES6
push
publish
Dev Machine
GitHub
npm
ES6
push
transpile & publishslow!
Publish-time
transpilation
Dev-time
transpilation
ES6 ES6
ES5 ES5
transpile
Publish-time transpilation
● Testing with babel-runtime
● No “dist” directory
● Transpile in a “prepublish” command
dist-es6
// package.json
{
"name": "kontainer-js",
"main": "src/index.js",
"bin": {
"kontainer": "src/cli.js"
},
"files": [
"README.md",
"logo.png",
"lib"
],
"scripts": {
"prepublish": "dist-es6"
},
npm install (local)
npm publish
1) creates node_modules/.bin/kontainer
#!/usr/bin/env node
require('dist-es6/lib/run').module('../src/cli.js');
2) copies src to node_modules/kontainer-js
You can require('kontainer-js') in spec files.
README.md
etc.
./dist
(temp dir)
./src
package.json
npm
copy
convert
publish
Huge win
● Speed (no transpilation in dev-time)
● Less complexity (no “dist” dir)
● Easy to debug (directly with ES6 code)
Some caveats
● Dependencies bomb (+294)
● Some publishing issue
Thanks!
kontainer-js
dist-es6

More Related Content

PDF
Restinio (actual aug 2018)
PDF
Talk on PHP Day Uruguay about Docker
PDF
Arbiter volumes in gluster
PDF
Hackersuli - Linux game hacking with LD_PRELOAD
PDF
LCA 2012: High Availability Sprint
ODP
Meetup #28
PDF
Restinio - header-only http and websocket server
PDF
Create a RESTful API with NodeJS, Express and MongoDB
Restinio (actual aug 2018)
Talk on PHP Day Uruguay about Docker
Arbiter volumes in gluster
Hackersuli - Linux game hacking with LD_PRELOAD
LCA 2012: High Availability Sprint
Meetup #28
Restinio - header-only http and websocket server
Create a RESTful API with NodeJS, Express and MongoDB

What's hot (20)

PDF
Boosting I/O Performance with KVM io_uring
PPT
Oreilly Webcast Jun17
DOCX
Bsdtw17: lightning talks/wip sessions
PDF
Docker Insight
PDF
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
PDF
Quick Introduction to Node.js
PPTX
Building High Performance Web Applications with the Windows Azure Platform
PDF
Compressed js with NodeJS & GruntJS
PDF
Node in Real Time - The Beginning
KEY
Redis overview for Software Architecture Forum
PDF
Easy access to open stack object storage
PDF
Deploying pNFS over Distributed File Storage w/ Jiffin Tony Thottan and Niels...
PPTX
Mongo db cluster administration and Shredded Databases
PDF
MongoDB, Node.js And You: PART II
ODP
Bullwinkle introduction
PPTX
what is docker
PDF
Ruby on embedded devices rug::b Aug 2014
PDF
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
PDF
MongoDB Replication Cluster
PPTX
Strategies for Backing Up MongoDB
Boosting I/O Performance with KVM io_uring
Oreilly Webcast Jun17
Bsdtw17: lightning talks/wip sessions
Docker Insight
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
Quick Introduction to Node.js
Building High Performance Web Applications with the Windows Azure Platform
Compressed js with NodeJS & GruntJS
Node in Real Time - The Beginning
Redis overview for Software Architecture Forum
Easy access to open stack object storage
Deploying pNFS over Distributed File Storage w/ Jiffin Tony Thottan and Niels...
Mongo db cluster administration and Shredded Databases
MongoDB, Node.js And You: PART II
Bullwinkle introduction
what is docker
Ruby on embedded devices rug::b Aug 2014
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
MongoDB Replication Cluster
Strategies for Backing Up MongoDB
Ad

Viewers also liked (20)

PPTX
JavaScript : What is it really? AND Some new features in ES6
PDF
Prototypeベース in JavaScript
PDF
jQuery勉強会#4
PDF
ES6 はじめました
PDF
JavaScript.Next Returns
PPTX
ES6 - JavaCro 2016
PDF
JavaScript 実践講座 Framework, Tool, Performance
PPTX
Getting started with ES6 : Future of javascript
PDF
150421 es6とかな話
PDF
FileReader and canvas and server silde
PDF
はじめてのWallaby.js
PDF
ECMAScript 6 Features(PDF 版)
PPTX
Startup JavaScript
PPT
Google App EngineでTwitterアプリを作ろう
PDF
アニメーションの実装つらい話
PPTX
Nds meetup8 lt
PDF
断言して間違えると信頼度が低下するというベイズの話
PDF
Hello npm
PDF
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
PDF
Learn ES2015
JavaScript : What is it really? AND Some new features in ES6
Prototypeベース in JavaScript
jQuery勉強会#4
ES6 はじめました
JavaScript.Next Returns
ES6 - JavaCro 2016
JavaScript 実践講座 Framework, Tool, Performance
Getting started with ES6 : Future of javascript
150421 es6とかな話
FileReader and canvas and server silde
はじめてのWallaby.js
ECMAScript 6 Features(PDF 版)
Startup JavaScript
Google App EngineでTwitterアプリを作ろう
アニメーションの実装つらい話
Nds meetup8 lt
断言して間違えると信頼度が低下するというベイズの話
Hello npm
Bacon.jsではじめる関数型リアアクティブプログラミング入門 with ES6
Learn ES2015
Ad

Similar to kontainer-js (20)

PDF
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
ODP
An MXM-based Application for Sharing Protected Content
PDF
Jason Anderson From Dirt Roads to Highways: Simplifying DevOps and Cloud Inf...
PPTX
Troubleshooting real production problems
PDF
Mongodb
PDF
Like loggly using open source
PDF
Fluentd and Embulk Game Server 4
PDF
Fluentd Unified Logging Layer At Fossasia
PDF
My name is Trinidad
PDF
Fluentd unified logging layer
PDF
How to deploy & optimize eZ Publish (2014)
KEY
#NewMeetup Performance
PDF
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
PPTX
RediSearch Mumbai Meetup 2020
PDF
Gnocchi v3 brownbag
PDF
Sandboxing WebKitGTK (GUADEC 2019)
PDF
Hartwarming lightning talk in winter Sapporo
PPTX
WordCamp Montreal 2016 WP-API + React with server rendering
PDF
Spatio-temporal Data Handling With GeoServer for MetOc And Remote Sensing
PDF
(C)NodeJS
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
An MXM-based Application for Sharing Protected Content
Jason Anderson From Dirt Roads to Highways: Simplifying DevOps and Cloud Inf...
Troubleshooting real production problems
Mongodb
Like loggly using open source
Fluentd and Embulk Game Server 4
Fluentd Unified Logging Layer At Fossasia
My name is Trinidad
Fluentd unified logging layer
How to deploy & optimize eZ Publish (2014)
#NewMeetup Performance
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
RediSearch Mumbai Meetup 2020
Gnocchi v3 brownbag
Sandboxing WebKitGTK (GUADEC 2019)
Hartwarming lightning talk in winter Sapporo
WordCamp Montreal 2016 WP-API + React with server rendering
Spatio-temporal Data Handling With GeoServer for MetOc And Remote Sensing
(C)NodeJS

Recently uploaded (20)

PDF
Five Habits of High-Impact Board Members
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPT
Geologic Time for studying geology for geologist
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
Build Your First AI Agent with UiPath.pptx
DOCX
search engine optimization ppt fir known well about this
PDF
CloudStack 4.21: First Look Webinar slides
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
TEXTILE technology diploma scope and career opportunities
PPTX
Configure Apache Mutual Authentication
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
Five Habits of High-Impact Board Members
Custom Battery Pack Design Considerations for Performance and Safety
sustainability-14-14877-v2.pddhzftheheeeee
Geologic Time for studying geology for geologist
Taming the Chaos: How to Turn Unstructured Data into Decisions
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
A review of recent deep learning applications in wood surface defect identifi...
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Build Your First AI Agent with UiPath.pptx
search engine optimization ppt fir known well about this
CloudStack 4.21: First Look Webinar slides
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Credit Without Borders: AI and Financial Inclusion in Bangladesh
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
Flame analysis and combustion estimation using large language and vision assi...
A contest of sentiment analysis: k-nearest neighbor versus neural network
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
TEXTILE technology diploma scope and career opportunities
Configure Apache Mutual Authentication
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide

kontainer-js

  • 1. kontainer-js Megro.es #3 Apr. 19th, 2016 at Drecom Kuu Miyazaki GitHub: @kuu Twitter: @miyazaqui
  • 2. kontainer-js > MP4 parser ● A parser/editor library written in ES2015 ● Runs both on Node.js and in the browser ● Provides its API as JSX
  • 3. MP4 > nested boxes
  • 4. MP4 > nested boxes ftyp moov mdat mvhd trak tkhd mdia ... length type property
  • 6. DOM > React > JSX Nested boxes
  • 7. How about writing MP4 in JSX?
  • 8. How about writing MP4 in JSX? render() { return ( <file> <ftyp majorBrand="isom" /> <moov> <mvhd creationTime={new Date()} timeScale={1} nextTrackId={4} /> <trak> <tkhd {...{trackId: 1, width: this.width, height: this.height}} /> <mdia> ...innerElements </mdia> </trak> </moov> <mdat data={buffer} /> </file> ); }
  • 10. How kontainer-js works { type: ‘ftype’, props : { majorBrand: ‘isom’, }, }, { type: ‘moov’, children: [ { type: ‘mvhd’, props: { timeScale: 1, … }, ] } parse serialize Byte stream JS object transpile JSX
  • 11. Development workflow Lint ● eslint Test ● [Browser] karma-jasmine + browserify(baberify) ● [Node] jasmine-es6 Build/Deploy ● [Browser] browserify(baberify) + uglify-js ● [Node] dist-es6 JSX Transpile ● Self-built Babel plugin (transform-kontainer-js)
  • 13. So, defer it as long as possible Dev Machine GitHub npm ES5 ES6 push publish Dev Machine GitHub npm ES6 push transpile & publishslow! Publish-time transpilation Dev-time transpilation ES6 ES6 ES5 ES5 transpile
  • 14. Publish-time transpilation ● Testing with babel-runtime ● No “dist” directory ● Transpile in a “prepublish” command
  • 15. dist-es6 // package.json { "name": "kontainer-js", "main": "src/index.js", "bin": { "kontainer": "src/cli.js" }, "files": [ "README.md", "logo.png", "lib" ], "scripts": { "prepublish": "dist-es6" }, npm install (local) npm publish 1) creates node_modules/.bin/kontainer #!/usr/bin/env node require('dist-es6/lib/run').module('../src/cli.js'); 2) copies src to node_modules/kontainer-js You can require('kontainer-js') in spec files. README.md etc. ./dist (temp dir) ./src package.json npm copy convert publish
  • 16. Huge win ● Speed (no transpilation in dev-time) ● Less complexity (no “dist” dir) ● Easy to debug (directly with ES6 code)
  • 17. Some caveats ● Dependencies bomb (+294) ● Some publishing issue