3.0.0 • Published 1 year ago

@dropb/ffprobe v3.0.0

Weekly downloads
20
License
MIT
Repository
github
Last release
1 year ago

@dropb/ffprobe

npm version Build status commits since latest release

simple ffprobe wrapper

Install

npm install  @dropb/ffprobe

Usage

// This is a hybrid module that can be loaded with import
import { ffprobe, ffprobeSync } from '@dropb/ffprobe';
// or require()
// const { ffprobe, ffprobeSync } = require('@dropb/ffprobe');

// optional: specify the ffprobe path
import { path as ffprobePath } from 'ffprobe-static';
ffprobe.path = ffprobePath;
// or
// process.env.FFPROBE_PATH = ffprobePath;



// 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 input FilePath / URL / Readable Stream
 */
function ffprobe(input: string | Stream): Promise<FfprobeData>;
function ffprobe(input: string | Stream, cb: FfprobeCallback): void;

interface FfprobeData

License

MIT

3.0.0

1 year ago

2.0.1

2 years ago

2.0.0

3 years ago

1.5.0

4 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago