Reputation: 49
I need to convert a JPG to 3-4sec long mp4 using NodeJS. Everywhere I search I find information about ffmpeg but nothing works for me. Currently I'm trying with fluent-ffmpeg. Here is my code:
let ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
let ffmpeg = require('fluent-ffmpeg')
ffmpeg.setFfmpegPath(ffmpegPath)
let command = ffmpeg()
command
.input(imagePath)
.inputFPS(1 / 5)
.outputFPS(30)
.videoCodec('libx264')
.videoBitrate(1024)
.size('640x?')
.loop(5)
.noAudio()
.on('end', () => {
resolve(saveTo)
}).save(saveTo)
I'm open for other NodeJs solutions as well. I've tried VideoShow library but it throws errors when an image is being uploaded from Android Phone.
Upvotes: 0
Views: 2605
Reputation: 49
I found this working for me:
let ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
let ffmpeg = require('fluent-ffmpeg')
ffmpeg.setFfmpegPath(ffmpegPath)
let command = ffmpeg(imagePath)
command
.inputFPS(1)
.outputFPS(30)
.videoCodec('libx264')
.videoBitrate(1024)
.size('640x?')
.loop(3.5)
.noAudio()
.save(saveTo)
Upvotes: 2