SlideShare a Scribd company logo
Open Source HTTP API for Media Encoding
Snickers
GoLab 2017. Florence, Italy
/flavioribeiro
/flavioribeiro
flavioribeiro.com
senior engineer @ the new york times
context
context
motivation
context
motivation
how it works?
context
motivation
how it works?
future
context
context
media factory
client
acquistion
API
media factory
API
transcoding
API
distribution
API
CDN
Storage
database
http://nyt.ms/mediafactory
transcoding api
transcoding
API
http://github.com/nytimes/video-transcoding-api
{	
  
	
  	
  "providers":	
  ["elastictranscoder",	
  "elementalconductor",	
  "encodingcom",	
  "zencoder"],

	
  	
  "preset":	
  {

	
  	
  	
  	
  "name":	
  "sample_preset",

	
  	
  	
  	
  "description":	
  "This	
  is	
  an	
  example	
  preset",

	
  	
  	
  	
  "container":	
  "mp4",

	
  	
  	
  	
  "rateControl":	
  "VBR",

	
  	
  	
  	
  "video":	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  "profile":	
  "Main",	
  "profileLevel":	
  "3.1",

	
  	
  	
  	
  	
  	
  	
  	
  "height":	
  "720",	
  "width":	
  "1080",

	
  	
  	
  	
  	
  	
  	
  	
  "codec":	
  "h264",	
  "bitrate":	
  "1000000",

	
  	
  	
  	
  	
  	
  	
  	
  "gopSize":	
  "90",	
  "gopMode":	
  "fixed",

	
  	
  	
  	
  	
  	
  	
  	
  "interlaceMode":	
  "progressive"

	
  	
  	
  	
  },

	
  	
  	
  	
  "audio":	
  {

	
  	
  	
  	
  	
  	
  	
  	
  "codec":	
  "aac",

	
  	
  	
  	
  	
  	
  	
  	
  "bitrate":	
  "64000"

	
  	
  	
  	
  }

}
transcoding api - presets
transcoding api - jobs
{	
  
	
  	
  "provider":	
  "elastictranscoder",

	
  	
  "source":	
  “ftp://nytimes:isg00d@ftp.nytimes.com/folder/my_video_source.mov”,	
  
	
  	
  “destination”:	
  “ftp://nytimes:isg00d@ftp.nytimes.com/outputs”,

	
  	
  "outputs":	
  [

	
  	
  	
  	
  {"preset":	
  "720p_mp4",	
  "fileName":	
  "my_video_720p.mp4"},

	
  	
  	
  	
  {"preset":	
  "1080p_mp4",	
  "fileName":	
  "my_video_1080p.mp4"},

	
  	
  	
  	
  {"preset":	
  "256p_hls",	
  "fileName":	
  "hls/my_video_480p.m3u8"},

	
  	
  	
  	
  {"preset":	
  "480p_hls",	
  "fileName":	
  "hls/my_video_480p.m3u8"},

	
  	
  	
  	
  {"preset":	
  "720p_hls",	
  "fileName":	
  "hls/my_video_720p.m3u8"},

	
  	
  	
  	
  {"preset":	
  "1080p_hls",	
  "fileName":	
  "hls/my_video_1080p.m3u8"},

	
  	
  	
  	
  {"preset":	
  "2160p_hls",	
  "fileName":	
  "hls/my_video_2160p.m3u8"}

	
  	
  ],	
  
	
  	
  "streamingParams":	
  {

	
  	
  	
  	
  "segmentDuration":	
  5,

	
  	
  	
  	
  "protocol":	
  "hls"

	
  	
  }

}	
  
• old system worked well for ~10 years, not anymore
• new system is a set of microservices in Go
• fast encoding, scalability, reliability
• transcoding API is a wrapper for encoding services
• presets, encoding jobs
context recap
motivation
motivation
• team fluent in Go — except me
motivation
• team fluent in Go — except me
• I wanted to test different approaches
motivation
• team fluent in Go — except me
• I wanted to test different approaches
• What if I create another encoding service in Go?
• open source alternative to encoding providers
• deploy & run everywhere
• add features any time
• compatible with transcoding api jobs and presets
What if I create another encoding service in Go?
how it works?
RESTful API
how it works?
var	
  Routes	
  =	
  map[Route]RouterArguments{	
  
	
  	
  //Job	
  routes	
  
	
  	
  CreateJob:	
  	
  	
  	
  	
  RouterArguments{Path:	
  "/jobs",	
  Method:	
  http.MethodPost},	
  
	
  	
  ListJobs:	
  	
  	
  	
  	
  	
  RouterArguments{Path:	
  "/jobs",	
  Method:	
  http.MethodGet},	
  
	
  	
  GetJobDetails:	
  RouterArguments{Path:	
  "/jobs/{jobID}",	
  Method:	
  http.MethodGet},	
  
	
  	
  StartJob:	
  	
  	
  	
  	
  	
  RouterArguments{Path:	
  "/jobs/{jobID}/start",	
  Method:	
  http.MethodPost},	
  
	
  	
  //Preset	
  routes	
  
	
  	
  CreatePreset:	
  	
  	
  	
  	
  RouterArguments{Path:	
  "/presets",	
  Method:	
  http.MethodPost},	
  
	
  	
  UpdatePreset:	
  	
  	
  	
  	
  RouterArguments{Path:	
  "/presets",	
  Method:	
  http.MethodPut},	
  
	
  	
  ListPresets:	
  	
  	
  	
  	
  	
  RouterArguments{Path:	
  "/presets",	
  Method:	
  http.MethodGet},	
  
	
  	
  GetPresetDetails:	
  RouterArguments{Path:	
  "/presets/{presetName}",	
  Method:	
  http.MethodGet},	
  
	
  	
  DeletePreset:	
  	
  	
  	
  	
  RouterArguments{Path:	
  "/presets/{presetName}",	
  Method:	
  http.MethodDelete},	
  
}
how it works?
server/routes.go
RESTful API
database
how it works?
RESTful API
database
pipeline
downloaders uploaders encoding engines
how it works?
func	
  StartJob(cfg	
  gonfig.Gonfig,	
  dbInstance	
  db.Storage,	
  job	
  types.Job)	
  {	
  
	
  	
  newJob,	
  err	
  :=	
  SetupJob(job.ID,	
  dbInstance,	
  cfg)	
  
	
  	
  job	
  =	
  *newJob	
  
	
  	
  if	
  err	
  !=	
  nil	
  {	
  
	
  	
  	
  	
  updateJobWithError(dbInstance,	
  job,	
  err.Error())	
  
	
  	
  	
  	
  return	
  
	
  }	
  
	
  	
  downloadFunc	
  :=	
  downloaders.GetDownloadFunc(job.Source)	
  
	
  	
  if	
  err	
  :=	
  downloadFunc(log,	
  cfg,	
  dbInstance,	
  job.ID);	
  err	
  !=	
  nil	
  {	
  
	
  	
  	
  	
  updateJobWithError(dbInstance,	
  job,	
  err.Error())	
  
	
  	
  	
  	
  return	
  
	
  }	
  
	
  	
  encodeFunc	
  :=	
  encoders.GetEncodeFunc(job)	
  
	
  	
  if	
  err	
  :=	
  encodeFunc(logger,	
  dbInstance,	
  job.ID);	
  err	
  !=	
  nil	
  {	
  
	
  	
  	
  	
  updateJobWithError(dbInstance,	
  job,	
  err.Error())	
  
	
  	
  	
  	
  return	
  
	
  	
  }	
  
	
  	
  uploadFunc	
  :=	
  uploaders.GetUploadFunc(job.Destination)	
  
	
  	
  if	
  err	
  :=	
  uploadFunc(logger,	
  dbInstance,	
  job.ID);	
  err	
  !=	
  nil	
  {	
  
	
  	
  	
  	
  updateJobWithError(dbInstance,	
  job,	
  err.Error())	
  
	
  	
  	
  	
  return	
  
	
  	
  }	
  
	
  	
  CleanSwap(dbInstance,	
  job.ID);	
  err	
  !=	
  nil	
  
	
  	
  job.Status	
  =	
  types.JobFinished	
  
	
  	
  dbInstance.UpdateJob(job.ID,	
  job)	
  
}	
  
how it works?
pipeline/pipeline.go
RESTful API
database
pipeline
downloaders uploaders encoding engines
ffmpeg binding
how it works?
how it works?
• encoding engines
• Cgo wrapper for FFmpeg functions
• https://github.com/3d0c/gmf
how it works?
package	
  segmenter	
  
/*	
  
#include	
  <stdio.h>	
  
#include	
  "libavformat/avformat.h"	
  
#include	
  <libavdevice/avdevice.h>	
  
#include	
  "c/segmenter.h"	
  
#include	
  "c/util.h"	
  
#cgo	
  LDFLAGS:	
  -­‐L${SRCDIR}/../build	
  -­‐lsegmenter	
  -­‐lavcodec	
  -­‐lavformat	
  -­‐lavutil	
  
*/	
  
import	
  "C"	
  
import	
  (	
  
	
   "fmt"	
  
	
   "os"	
  
	
   "unsafe"	
  
	
   "github.com/3d0c/gmf"	
  
)	
  
DEMO!
future
future
transcoding
API
future
• multibitrate HLS
• go client (WIP)
• add another encoding engine using GStreamer
We’re hiring
nyti.ms/technology
@NYTDevs | developers.nytimes.com
Stay updated
open.blogs.nytimes.com
@NYTDevs | developers.nytimes.com
Connect with us on Slack!
http://video-dev.org
@NYTDevs | developers.nytimes.com
thank you!
{ , } /flavioribeiro

More Related Content

What's hot

Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
Lin Yo-An
 
Trading with opensource tools, two years later
Trading with opensource tools, two years laterTrading with opensource tools, two years later
Trading with opensource tools, two years later
clkao
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
Giordano Scalzo
 

What's hot (20)

ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
NativeBoost
NativeBoostNativeBoost
NativeBoost
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
Txjs
TxjsTxjs
Txjs
 
Trading with opensource tools, two years later
Trading with opensource tools, two years laterTrading with opensource tools, two years later
Trading with opensource tools, two years later
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
Minimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team ProductivityMinimizing Decision Fatigue to Improve Team Productivity
Minimizing Decision Fatigue to Improve Team Productivity
 
Mastering Kotlin Standard Library
Mastering Kotlin Standard LibraryMastering Kotlin Standard Library
Mastering Kotlin Standard Library
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
 
JavaScript ES6
JavaScript ES6JavaScript ES6
JavaScript ES6
 
Python Coroutines, Present and Future
Python Coroutines, Present and FuturePython Coroutines, Present and Future
Python Coroutines, Present and Future
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackAplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & Jetpack
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 

Similar to Snickers: Open Source HTTP API for Media Encoding

Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
維佋 唐
 
Running gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesRunning gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on Kubernetes
Sungwon Lee
 

Similar to Snickers: Open Source HTTP API for Media Encoding (20)

Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyond
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...Choisir entre une API  RPC, SOAP, REST, GraphQL?  
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
 
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
 
Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)
 
Vue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMRVue.js + Django - configuración para desarrollo con webpack y HMR
Vue.js + Django - configuración para desarrollo con webpack y HMR
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0
 
Automated infrastructure is on the menu
Automated infrastructure is on the menuAutomated infrastructure is on the menu
Automated infrastructure is on the menu
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in Kotlin
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
Serve Meals, Not Ingredients (ChefConf 2015)
Serve Meals, Not Ingredients (ChefConf 2015)Serve Meals, Not Ingredients (ChefConf 2015)
Serve Meals, Not Ingredients (ChefConf 2015)
 
Serve Meals, Not Ingredients - ChefConf 2015
Serve Meals, Not Ingredients - ChefConf 2015Serve Meals, Not Ingredients - ChefConf 2015
Serve Meals, Not Ingredients - ChefConf 2015
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
 
Node in Production at Aviary
Node in Production at AviaryNode in Production at Aviary
Node in Production at Aviary
 
Running gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on KubernetesRunning gRPC Services for Serving Legacy API on Kubernetes
Running gRPC Services for Serving Legacy API on Kubernetes
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 

More from Flávio Ribeiro

BemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-Peer
BemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-PeerBemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-Peer
BemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-Peer
Flávio Ribeiro
 
Test Driven Development - Trabalhe tranquilo e maximize sua produtividade
Test Driven Development - Trabalhe tranquilo e maximize sua produtividadeTest Driven Development - Trabalhe tranquilo e maximize sua produtividade
Test Driven Development - Trabalhe tranquilo e maximize sua produtividade
Flávio Ribeiro
 

More from Flávio Ribeiro (15)

Building a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York TimesBuilding a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York Times
 
Towards the Application of WebRTC Peer-to-Peer to Scale Live Video Streaming ...
Towards the Application of WebRTC Peer-to-Peer to Scale Live Video Streaming ...Towards the Application of WebRTC Peer-to-Peer to Scale Live Video Streaming ...
Towards the Application of WebRTC Peer-to-Peer to Scale Live Video Streaming ...
 
Implementação de Aplicações Móveis e Jogos com Python - Aula 3
Implementação de Aplicações Móveis e Jogos com Python - Aula 3Implementação de Aplicações Móveis e Jogos com Python - Aula 3
Implementação de Aplicações Móveis e Jogos com Python - Aula 3
 
Implementação de Aplicações Móveis e Jogos com Python - Aula 5
Implementação de Aplicações Móveis e Jogos com Python - Aula 5Implementação de Aplicações Móveis e Jogos com Python - Aula 5
Implementação de Aplicações Móveis e Jogos com Python - Aula 5
 
Implementação de Aplicações Móveis e Jogos com Python - Aula 6
Implementação de Aplicações Móveis e Jogos com Python - Aula 6Implementação de Aplicações Móveis e Jogos com Python - Aula 6
Implementação de Aplicações Móveis e Jogos com Python - Aula 6
 
Implementação de Aplicações Móveis e Jogos com Python - Aula 4
Implementação de Aplicações Móveis e Jogos com Python - Aula 4Implementação de Aplicações Móveis e Jogos com Python - Aula 4
Implementação de Aplicações Móveis e Jogos com Python - Aula 4
 
Implementação de Aplicações Móveis e Jogos com Python - Aula 2
Implementação de Aplicações Móveis e Jogos com Python - Aula 2Implementação de Aplicações Móveis e Jogos com Python - Aula 2
Implementação de Aplicações Móveis e Jogos com Python - Aula 2
 
Implementação de Aplicações Móveis e Jogos com Python - Aula 1
Implementação de Aplicações Móveis e Jogos com Python - Aula 1Implementação de Aplicações Móveis e Jogos com Python - Aula 1
Implementação de Aplicações Móveis e Jogos com Python - Aula 1
 
BemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-Peer
BemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-PeerBemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-Peer
BemTV: Modelo Híbrido para Transmissão de Vídeos ao Vivo utilizando Peer-to-Peer
 
Desenvolvimento Mobile & Embedded com Arduino, Python, ARM e Linux
Desenvolvimento Mobile & Embedded com Arduino, Python, ARM e LinuxDesenvolvimento Mobile & Embedded com Arduino, Python, ARM e Linux
Desenvolvimento Mobile & Embedded com Arduino, Python, ARM e Linux
 
stewie: Machine Learning para detecção não supervisionada de anomalias
stewie: Machine Learning para detecção não supervisionada de anomaliasstewie: Machine Learning para detecção não supervisionada de anomalias
stewie: Machine Learning para detecção não supervisionada de anomalias
 
Test Driven Development - Trabalhe tranquilo e maximize sua produtividade
Test Driven Development - Trabalhe tranquilo e maximize sua produtividadeTest Driven Development - Trabalhe tranquilo e maximize sua produtividade
Test Driven Development - Trabalhe tranquilo e maximize sua produtividade
 
Desenvolvimento de aplicações embarcadas utilizando Python
Desenvolvimento de aplicações embarcadas utilizando PythonDesenvolvimento de aplicações embarcadas utilizando Python
Desenvolvimento de aplicações embarcadas utilizando Python
 
Introdução a Linguagem de Programação Python
Introdução a Linguagem de Programação PythonIntrodução a Linguagem de Programação Python
Introdução a Linguagem de Programação Python
 
Linux em Sistemas Embarcados
Linux em Sistemas EmbarcadosLinux em Sistemas Embarcados
Linux em Sistemas Embarcados
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 

Snickers: Open Source HTTP API for Media Encoding

  • 1. Open Source HTTP API for Media Encoding Snickers GoLab 2017. Florence, Italy
  • 10. {      "providers":  ["elastictranscoder",  "elementalconductor",  "encodingcom",  "zencoder"],
    "preset":  {
        "name":  "sample_preset",
        "description":  "This  is  an  example  preset",
        "container":  "mp4",
        "rateControl":  "VBR",
        "video":  {                  "profile":  "Main",  "profileLevel":  "3.1",
                "height":  "720",  "width":  "1080",
                "codec":  "h264",  "bitrate":  "1000000",
                "gopSize":  "90",  "gopMode":  "fixed",
                "interlaceMode":  "progressive"
        },
        "audio":  {
                "codec":  "aac",
                "bitrate":  "64000"
        }
 } transcoding api - presets
  • 11. transcoding api - jobs {      "provider":  "elastictranscoder",
    "source":  “ftp://nytimes:isg00d@ftp.nytimes.com/folder/my_video_source.mov”,      “destination”:  “ftp://nytimes:isg00d@ftp.nytimes.com/outputs”,
    "outputs":  [
        {"preset":  "720p_mp4",  "fileName":  "my_video_720p.mp4"},
        {"preset":  "1080p_mp4",  "fileName":  "my_video_1080p.mp4"},
        {"preset":  "256p_hls",  "fileName":  "hls/my_video_480p.m3u8"},
        {"preset":  "480p_hls",  "fileName":  "hls/my_video_480p.m3u8"},
        {"preset":  "720p_hls",  "fileName":  "hls/my_video_720p.m3u8"},
        {"preset":  "1080p_hls",  "fileName":  "hls/my_video_1080p.m3u8"},
        {"preset":  "2160p_hls",  "fileName":  "hls/my_video_2160p.m3u8"}
    ],      "streamingParams":  {
        "segmentDuration":  5,
        "protocol":  "hls"
    }
 }  
  • 12. • old system worked well for ~10 years, not anymore • new system is a set of microservices in Go • fast encoding, scalability, reliability • transcoding API is a wrapper for encoding services • presets, encoding jobs context recap
  • 14. motivation • team fluent in Go — except me
  • 15. motivation • team fluent in Go — except me • I wanted to test different approaches
  • 16. motivation • team fluent in Go — except me • I wanted to test different approaches • What if I create another encoding service in Go?
  • 17. • open source alternative to encoding providers • deploy & run everywhere • add features any time • compatible with transcoding api jobs and presets What if I create another encoding service in Go?
  • 18.
  • 21. var  Routes  =  map[Route]RouterArguments{      //Job  routes      CreateJob:          RouterArguments{Path:  "/jobs",  Method:  http.MethodPost},      ListJobs:            RouterArguments{Path:  "/jobs",  Method:  http.MethodGet},      GetJobDetails:  RouterArguments{Path:  "/jobs/{jobID}",  Method:  http.MethodGet},      StartJob:            RouterArguments{Path:  "/jobs/{jobID}/start",  Method:  http.MethodPost},      //Preset  routes      CreatePreset:          RouterArguments{Path:  "/presets",  Method:  http.MethodPost},      UpdatePreset:          RouterArguments{Path:  "/presets",  Method:  http.MethodPut},      ListPresets:            RouterArguments{Path:  "/presets",  Method:  http.MethodGet},      GetPresetDetails:  RouterArguments{Path:  "/presets/{presetName}",  Method:  http.MethodGet},      DeletePreset:          RouterArguments{Path:  "/presets/{presetName}",  Method:  http.MethodDelete},   } how it works? server/routes.go
  • 23. RESTful API database pipeline downloaders uploaders encoding engines how it works?
  • 24. func  StartJob(cfg  gonfig.Gonfig,  dbInstance  db.Storage,  job  types.Job)  {      newJob,  err  :=  SetupJob(job.ID,  dbInstance,  cfg)      job  =  *newJob      if  err  !=  nil  {          updateJobWithError(dbInstance,  job,  err.Error())          return    }      downloadFunc  :=  downloaders.GetDownloadFunc(job.Source)      if  err  :=  downloadFunc(log,  cfg,  dbInstance,  job.ID);  err  !=  nil  {          updateJobWithError(dbInstance,  job,  err.Error())          return    }      encodeFunc  :=  encoders.GetEncodeFunc(job)      if  err  :=  encodeFunc(logger,  dbInstance,  job.ID);  err  !=  nil  {          updateJobWithError(dbInstance,  job,  err.Error())          return      }      uploadFunc  :=  uploaders.GetUploadFunc(job.Destination)      if  err  :=  uploadFunc(logger,  dbInstance,  job.ID);  err  !=  nil  {          updateJobWithError(dbInstance,  job,  err.Error())          return      }      CleanSwap(dbInstance,  job.ID);  err  !=  nil      job.Status  =  types.JobFinished      dbInstance.UpdateJob(job.ID,  job)   }   how it works? pipeline/pipeline.go
  • 25. RESTful API database pipeline downloaders uploaders encoding engines ffmpeg binding how it works?
  • 26. how it works? • encoding engines • Cgo wrapper for FFmpeg functions • https://github.com/3d0c/gmf
  • 27. how it works? package  segmenter   /*   #include  <stdio.h>   #include  "libavformat/avformat.h"   #include  <libavdevice/avdevice.h>   #include  "c/segmenter.h"   #include  "c/util.h"   #cgo  LDFLAGS:  -­‐L${SRCDIR}/../build  -­‐lsegmenter  -­‐lavcodec  -­‐lavformat  -­‐lavutil   */   import  "C"   import  (     "fmt"     "os"     "unsafe"     "github.com/3d0c/gmf"   )  
  • 28. DEMO!
  • 29.
  • 32. future • multibitrate HLS • go client (WIP) • add another encoding engine using GStreamer
  • 35. Connect with us on Slack! http://video-dev.org @NYTDevs | developers.nytimes.com
  • 36. thank you! { , } /flavioribeiro