var ffmpeg = require('fluent-ffmpeg');
// make sure you set the correct path to your video file
var proc = ffmpeg(__dirname + "/imageSource/seq0.jpg")
.videoCodec('libx264')
.format('mp4')
.loop(5)
.fps(25)
.on('end', function() {
console.log('file has been converted succesfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
.save(__dirname + "/output/renderResult.mp4");
(note: if the problem only happens with some inputs, include a link to such an input file)
Output video file to .mp4, file can be played in popular video players and HTML5 players
Output video file to .mp4, file can be only played in Chrome HTML5 players and VLC player.
In quicktime:
"The file isn鈥檛 compatible with QuickTime Player."
In firefox:
"Video can't be played because the file is corrupt."
I tried with commend line ffmpeg, it seems I have to add "-pix_fmt yuv420p", can anyone tell me how I do this with in my node.js code? Thanks.
solved! By add .outputOptions('-pix_fmt yuv420p'),
Close.
Hey. I'm hoping you can help me. I am now receiving this error when running your example:
UnhandledPromiseRejectionWarning: Error: ffmpeg exited with code 1: Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe
incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Any idea as to what I should do? Thanks in advance
Most helpful comment
solved! By add .outputOptions('-pix_fmt yuv420p'),
Close.