1

I'm using following npm package in NodeJS application. What I need to do is reduce the size of videos. My videos are in mp4 format. Is there any way to reduce size of those videos using node-ffmpeg ? https://www.npmjs.com/package/ffmpeg

There are not good answers or samples. I followed this code some steps and idea, but no good. fluent ffmpeg size output option not working

In normal ffmpeg, we can do like this.

ffmpeg -i <inputfilename> -s 640x480 -b:v 512k -vcodec mpeg1video -acodec copy <outputfilename>

How can we do the same in NodeJS ?

Please help me on this. any sample code or idea is welcome.

Chanaka De Silva
  • 401
  • 9
  • 20
  • Possible duplicate of [Reducing video size with same format and reducing frame size](https://stackoverflow.com/questions/4490154/reducing-video-size-with-same-format-and-reducing-frame-size) – OrangeDog Jan 18 '18 at 16:08
  • @OrangeDog Oh, thanks buddy. I think that's really basic. Like only executing some terminal command. I though a lot of this npm module. :-( Anyway, thanks buddy – Chanaka De Silva Jan 18 '18 at 16:27

1 Answers1

2

Just use child_process. That's all that the node modules do.

e.g.

child_process.execFile('ffmpeg', [
    '-i', inputfilename,
    '-s', '640x480',
    '-b:v', '512k',
    '-c:v', 'mpeg1video',
    '-c:a', 'copy',
    outputfilename
], function(error, stdout, stderr) {
    // ...
})

I would avoid using any modules as they obfuscate what commands they're actually running, and if you want to do something more advanced that they haven't added code for then you're stuck.

OrangeDog
  • 36,653
  • 12
  • 122
  • 207