Have ideas to improve npm?Join in the discussion! »

@dropb/ffprobe
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@dropb/ffprobe

npm build

simple ffprobe wrapper

Install

npm install  @dropb/ffprobe

Usage

import { ffprobe, ffprobeSync } from '@dropb/ffprobe';
// optional: specify the ffprobe path
import * as ffprobeStatic from 'ffprobe-static';
process.env.FFPROBE_PATH = ffprobeStatic.path;
// or
// ffprobe.path = ffprobeStatic.path;

// async/await
async function run() {
  try {
    // file
    const data = await ffprobe('./testfile.mp4');
    console.log(data.format.duration);
  } catch (e) {
    console.error(e);
  }
  try {
    // URL
    const { streams } = await ffprobe('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4');
    console.log(streams[0].width);
  } catch (e) {
    console.error(e);
  }
  try {
    // Readable Stream
    const { format } = await ffprobe(createReadStream('./testfile.mp4'));
    console.log(format.duration);
  } catch (e) {
    console.error(e);
  }
}
run();

// node-style callback
ffprobe('./testfile.mp4', (err, data) => {
  if (err) {
    console.error(err);
  } else {
    console.log(data.format.duration);
  }
});

// sync
const data = ffprobeSync('./testfile.mp4');
console.log(data.format.duration);

API

/**
 *
 * Run ffprobe on specified input
 * @param src FilePath / URL / Readable Stream
 */
function ffprobe(input: string | Stream): Promise<FfprobeData>;
function ffprobe(input: string | Stream, cb: (err: Error, data?: FfprobeData) => void): void;

interface FfprobeData

License

MIT

Keywords

none

Install

npm i @dropb/ffprobe

DownloadsWeekly Downloads

130

Version

2.0.0

License

MIT

Unpacked Size

10.8 kB

Total Files

9

Last publish

Collaborators

  • avatar