Node-fluent-ffmpeg: Convert from image/jpg to mp4, output file cannot playing on MacOS

Created on 22 Jan 2018  路  3Comments  路  Source: fluent-ffmpeg/node-fluent-ffmpeg

Version information

  • fluent-ffmpeg version: [email protected](current latest)
  • ffmpeg version: 3.4.1
  • OS: MacOS/OSX High Sierra 10.13.2

Code to reproduce

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)

Expected results

Output video file to .mp4, file can be played in popular video players and HTML5 players

Observed results

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."

Most helpful comment

solved! By add .outputOptions('-pix_fmt yuv420p'),

Close.

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

345ml picture 345ml  路  6Comments

xyk2 picture xyk2  路  3Comments

timkendall picture timkendall  路  7Comments

joergbirkhold picture joergbirkhold  路  5Comments

LauraWebdev picture LauraWebdev  路  3Comments