ffprobe-client
A zero-dependency, promise-based Node.js API for ffprobe
.
Below is a comparison between ffprobe-client
and other popular ffprobe
libraries, as of August 23rd, 2018:
ffprobe-client | ffprobe | node-ffprobe | |
---|---|---|---|
promise API | ✔ | ✔ | ✘ |
custom ffprobe path | ✔ | ✔ | ✘ |
-show_format | ✔ | ✘ | ✔ |
electron support1 | ✔ | ✘ | ✘ |
dependencies | none! | JSONStream, bl, deferential | none! |
last publish | 2018-08-23 | 2016-01-02 | 2013-04-20 |
Usage
// optional: specify a binary path, see configprocessenvFFPROBE_PATH = '/usr/bin/ffprobe'const ffprobe = const file = './path/to/file'const url = 'http://www.example.com/foo.webm' // promise // async/await { try const data = await console catch err console }
API
ffprobe(target, [config])
Returns a Promise
which resolves to a JSON
outputted by ffprobe
.
target
Type: String
The file path or URL of the stream for ffprobe
to analyze. Older versions of ffprobe
seem to segfault when passed in a URL; please try to keep your ffprobe
binary up to date.
config
Type: Object
A configuration object, see details below.
config.path
Type: String
The path of the ffprobe
binary. If omitted, the path will be set to the FFPROBE_PATH
environment variable. If the environment variable is not set, ffprobe
will be invoked directly (ie. ffprobe [...]
).
Payload
Below is an example payload. Note that keys will be omitted if ffprobe
fails to generate the data.
Testing Locally
Run ./scripts/gen-output.sh
before running the tests; this command will generate the expected JSON snapshot.