node js ffmpeg image to video

Solutions on MaxInterview for node js ffmpeg image to video by the best coders in the world

showing results for - "node js ffmpeg image to video"
Angèle
22 May 2017
1const frames = ['frame1.jpg', 'frame2.jpg', ...]
2
3const conv = ffmpeg() // create converter
4const input = conv.input({f: 'image2pipe', r: 30}) // create input writable stream
5conv.output('out.mp4', {vcodec: 'libx264', pix_fmt: 'yuv420p'}) // output to file
6
7// for every frame create a function that returns a promise
8frames.map(filename => () =>
9  new Promise((fulfill, reject) =>
10    s3
11      .getObject({Bucket: '...', Key: filename})
12      .createReadStream()
13      .on('end', fulfill) // fulfill promise on frame end
14      .on('error', reject) // reject promise on error
15      .pipe(input, {end: false}) // pipe to converter, but don't end the input yet
16  )
17)
18// reduce into a single promise, run sequentially
19.reduce((prev, next) => prev.then(next), Promise.resolve())
20// end converter input
21.then(() => input.end())
22
23conv.run()