natural-language-api-google/utils/getAudioDuration.js

18 lines
391 B
JavaScript

const ffmpeg = require('fluent-ffmpeg')
async function getAudioDuration(filePath) {
return new Promise((resolve, reject) => {
ffmpeg.ffprobe(filePath, (err, metadata) => {
if (err) {
reject(err)
} else {
resolve(Math.round(metadata.format.duration))
}
})
})
}
module.exports = getAudioDuration