Reputation: 738
I"m using ffmpeg to covnert a list of images to a timelapse video. When i run the command from the commandline its works beautifully.
ffmpeg -r 3 -i /var/folders/qj/n910kwdj4gvbmy_z2ffc5lcc0000gp/T/tmp-22129yvIsrbso4TEu/image%03d.jpg -s hd1080 -vcodec libx264 timelapse.mp4
The issue occurs when i use nodejs library fluent-ffmpeg.
app.get('/api/get', function (req, res) {// return new Promise((resolve, reject) => {
ffmpeg('/var/folders/qj/n910kwdj4gvbmy_z2ffc5lcc0000gp/T/tmp-22129yvIsrbso4TEu/image%03d.jpg')
.noAudio()
.inputOption('-r 3')
.outputOptions([
'-r', '3',
'-s', 'hd1080'
]).
.videoCodec('libx264')
.on('progress', (progress) => {
console.log('Processing: ' + progress.percent + '% done');
})
.on('error', (err) => {
console.error('Error during processing', err);
// reject(err)
})
.on('end', () => {
console.log('Processing finished !');
// resolve()
})
.save('test.mp4', {end: true});
}
res.send(`I received your GET request.`);
});
EDIT: Now gives me a processed video at Processing: 207.49999999999997% done Processing finished ! but doesn't produce a video
And my images are named as so image1.jpg, image2.jpg, image3.jpg, etc
Its very confusing when i run the command directly in my cli.
Anyone run into this issue before or am i just using the library wrong?
Upvotes: 0
Views: 589
Reputation: 1738
The fact you're converting only 41.25% might be caused by the type of pattern used here image%d.jpg. When using ffmpeg -r 3 -i /var/folders/qj/n910kwdj4gvbmy_z2ffc5lcc0000gp/T/tmp-22129yvIsrbso4TEu/image%d.jpg -s hd1080 -vcodec libx264 timelapse.mp4
You must have a sequence of images like:
In having image-9.png after image-4.png. The video ends up at image-4.png. So you have 2 choices here. Make sure you have the correct number sequence in all filenames or use a glob pattern.
If you're looking for a glob pattern:
app.get('/api/get', function (req, res) {// return new Promise((resolve, reject) => {
ffmpeg('/var/folders/qj/n910kwdj4gvbmy_z2ffc5lcc0000gp/T/tmp-22129yvIsrbso4TEu/image*.jpg')
.noAudio()
.outputOptions([
'-r', '3',
'-s', 'hd1080'
]).
.videoCodec('libx264')
.on('progress', (progress) => {
console.log('Processing: ' + progress.percent + '% done');
})
.on('error', (err) => {
console.error('Error during processing', err);
// reject(err)
})
.on('end', () => {
console.log('Processing finished !');
// resolve()
})
.save('test.mp4', {end: true});
}
res.send(`I received your GET request.`);
});
Reference here: http://trac.ffmpeg.org/wiki/Slideshow#Globpattern
Upvotes: 1