I am using fluent-ffmpeg in my code, my main goal is to get the audio/video duration, I need to use stream as my input.
According the document, https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#reading-video-metadata
ffmpeg('/path/to/file1.avi')
.input('/path/to/file2.avi')
.ffprobe(function(err, data) {
console.log('file2 metadata:');
console.dir(data);
});
ffmpeg('/path/to/file1.avi')
.input('/path/to/file2.avi')
.ffprobe(0, function(err, data) {
console.log('file1 metadata:');
console.dir(data);
});
I have tried these
const ffmpeg = require('fluent-ffmpeg')
const fs = require('fs')
filepath = './scratch_file/assets_audios_10000.wav'
stream = fs.createReadStream(filepath)
ffmpeg(stream)
.input(filepath) // have to put a file path here, possible path dependent
.ffprobe(function (err, metadata) {
if (err){throw err}
console.log(metadata.format.duration);
}) //success printing the duration
Above successfully returned the duration
ffmpeg(stream)
.input(stream) //
.ffprobe(function (err, metadata) {
if (err){throw err}
console.log(metadata.format.duration);
}) // failed
Above failed.
ffmpeg(stream)
.ffprobe(function (err, metadata) {
if (err){throw err}
console.log(metadata.format.duration);
}) //returned "N/A"
Returned N/A
Can nyone help? I would need something like
ffmpeg.ffprobe(stream, (metadata) => {console.log(metadata.format.duration)} )
Thank you.