mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-03 16:59:41 +00:00
Remove node-ffprobe dependency
This commit is contained in:
parent
d0af1c3c9a
commit
8562b8d1b3
5 changed files with 51 additions and 7 deletions
28
server/libs/nodeFfprobe/index.js
Normal file
28
server/libs/nodeFfprobe/index.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// node-ffprobe modified for audiobookshelf
|
||||
// SOURCE: https://github.com/ListenerApproved/node-ffprobe
|
||||
//
|
||||
|
||||
const spawn = require('child_process').spawn
|
||||
|
||||
module.exports = (function () {
|
||||
function doProbe(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let proc = spawn(module.exports.FFPROBE_PATH || 'ffprobe', ['-hide_banner', '-loglevel', 'fatal', '-show_error', '-show_format', '-show_streams', '-show_programs', '-show_chapters', '-show_private_data', '-print_format', 'json', file])
|
||||
let probeData = []
|
||||
let errData = []
|
||||
|
||||
proc.stdout.setEncoding('utf8')
|
||||
proc.stderr.setEncoding('utf8')
|
||||
|
||||
proc.stdout.on('data', function (data) { probeData.push(data) })
|
||||
proc.stderr.on('data', function (data) { errData.push(data) })
|
||||
|
||||
proc.on('exit', code => { exitCode = code })
|
||||
proc.on('error', err => reject(err))
|
||||
proc.on('close', () => resolve(JSON.parse(probeData.join(''))))
|
||||
})
|
||||
}
|
||||
|
||||
return doProbe
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue