Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node js ffmpeg image to video

const frames = ['frame1.jpg', 'frame2.jpg', ...]

const conv = ffmpeg() // create converter
const input = conv.input({f: 'image2pipe', r: 30}) // create input writable stream
conv.output('out.mp4', {vcodec: 'libx264', pix_fmt: 'yuv420p'}) // output to file

// for every frame create a function that returns a promise
frames.map(filename => () =>
  new Promise((fulfill, reject) =>
    s3
      .getObject({Bucket: '...', Key: filename})
      .createReadStream()
      .on('end', fulfill) // fulfill promise on frame end
      .on('error', reject) // reject promise on error
      .pipe(input, {end: false}) // pipe to converter, but don't end the input yet
  )
)
// reduce into a single promise, run sequentially
.reduce((prev, next) => prev.then(next), Promise.resolve())
// end converter input
.then(() => input.end())

conv.run()
Comment

PREVIOUS NEXT
Code Example
Javascript :: textarea javascript set value 
Javascript :: how to install jsonwebtoken in next js 
Javascript :: merge 2 array of object by key 
Javascript :: js remove last character 
Javascript :: how to seperate words seperated by commas using javascript 
Javascript :: debounce 
Javascript :: js encode url 
Javascript :: set background image URL jQuery 
Javascript :: jquery validator add method 
Javascript :: stringify json javascript 
Javascript :: vue mounted refresh page once 
Javascript :: javascript get image dimensions 
Javascript :: what is node.js 
Javascript :: onsubmit in reactjs 
Javascript :: using bootstrap with react 
Javascript :: jquery select html element 
Javascript :: apply css to iframe content javascript 
Javascript :: unidirectional data flow 
Javascript :: react electron boilerplate 
Javascript :: js for loops 
Javascript :: cypress store cookies 
Javascript :: angular get device information 
Javascript :: js time function 
Javascript :: sort li elements with js 
Javascript :: javascript how to get subarray 
Javascript :: javascript add event listenner for multiple events 
Javascript :: jquery timepicker get value onchange 
Javascript :: creating 2d array in javascript 
Javascript :: moment.js 
Javascript :: js mouse move activate 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =