# ffprobe

> Use ffprobe to get info from media files and return as JSON

Latest version **1.1.2** (published 2020-09-09) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install ffprobe
pnpm add ffprobe
yarn add ffprobe
bun add ffprobe
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2020-09-09 |
| First published | 2016-01-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | separate (@types/ffprobe) |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 21.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 102 |
| Author | Eugene Ware |
| Maintainers | eugeneware |
| Keywords | json, ffmpeg, ffprobe, media, video, audio, image, images |

## Links

- npm: https://www.npmjs.com/package/ffprobe
- Repository: https://github.com/eugeneware/ffprobe
- Homepage: https://github.com/eugeneware/ffprobe#readme
- Issues: https://github.com/eugeneware/ffprobe/issues
- npm.io page: https://npm.io/package/ffprobe

## Dependencies (3)

- [bl](https://npm.io/package/bl.md) ^4.0.3
- [JSONStream](https://npm.io/package/JSONStream.md) ^1.3.5
- [deferential](https://npm.io/package/deferential.md) ^1.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.2 (latest) — 2020-09-09
- 1.1.1 — 2020-09-09
- 1.1.0 — 2016-01-02
- 1.0.0 — 2016-01-02

## README

# ffprobe

Use ffprobe to get info from media files and return as JSON

[![build status](https://secure.travis-ci.org/eugeneware/ffprobe.png)](http://travis-ci.org/eugeneware/ffprobe)

## Installation

This module is installed via npm:

``` bash
$ npm install ffprobe
```

## Example Usage

`ffprobe` is a *dual* API, supporting both node.js callbacks *AND* `Promise`s.

### Callback API
List the output of ffprobe for a media file in a convenient JSON format:

``` js
var ffprobe = require('ffprobe'),
    ffprobeStatic = require('ffprobe-static');

ffprobe('./file.mp4', { path: ffprobeStatic.path }, function (err, info) {
  if (err) return done(err);
  console.log(info);
/***
{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_time_base": "1/50",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 1280,
            "height": 720,
            "coded_width": 1280,
            "coded_height": 720,
            "has_b_frames": 0,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "16:9",
            "pix_fmt": "yuv420p",
            "level": 31,
            "chroma_location": "left",
            "refs": 1,
            "is_avc": "1",
            "nal_length_size": "4",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/25",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 299,
            "duration": "11.960000",
            "bit_rate": "1031739",
            "bits_per_raw_sample": "8",
            "nb_frames": "299",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_time_base": "1/44100",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/44100",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 528384,
            "duration": "11.981497",
            "bit_rate": "192287",
            "max_bit_rate": "203120",
            "nb_frames": "516",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0
            },
            "tags": {
                "creation_time": "2015-11-16 00:48:42",
                "language": "eng",
                "handler_name": "IsoMedia File Produced by Google, 5-11-2011"
            }
        }
    ]
}
 **/
});
```

### Promise API
List the output of ffprobe for a media file in a convenient JSON format:

``` js
var ffprobe = require('ffprobe'),
    ffprobeStatic = require('ffprobe-static');

ffprobe('./file.mp4', { path: ffprobeStatic.path })
  .then(function (info) {
    console.log(info);
    /***
    {
        "streams": [
            {
                "index": 0,
                "codec_name": "h264",
                "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
                "profile": "High",

                ...
                }
            }
        ]
    }
     **/
  })
  .catch(function (err) {
    console.error(err);
  })
});
```

## API

### `ffprobe(mediaFilePath, opts, [cb])`

* `mediaFilePath` - path to your audio / video / image that you want to get media
  info for.
* `opts` - options object with the following options:
  * `path` - path to ffprobe binary (You can use
    [`ffprobe-static`](https://github.com/joshwnj/ffprobe-static) to easily get
    a static binary that you can install with npm.
* `cb(err, info)` - standard callback, with the info returned as a javascript
  object. NB: If the `cb` parameter is not provided, a `Promise` will be returned
  allowing chained `then()`, `catch()` methods.

---
_Source: https://npm.io/package/ffprobe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
