video-size

Get the width and height of a video using ffprobe.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install
Install with npm:
$ npm install --save video-size
Usage
The module provides both async and sync methods to extract video dimensions.
Async Usage
To use the asynchronous function, import videoSize and call it with the path to the video file:
import { videoSize } from 'video-size';
videoSize('path/to/video.mp4')
.then(dimensions => console.log(dimensions))
.catch(err => console.error(err));
Sync Usage
For synchronous usage, you can use the videoSizeSync function:
import { videoSizeSync } from 'video-size';
const dimensions = videoSizeSync('path/to/video.mp4');
console.log(dimensions);
API
videoSize(filepath: string): Promise<{ width: number; height: number }>
- filepath:
string - Path to the video file.
- returns:
Promise<{ width: number; height: number }> - A promise that resolves with an object containing the width and height of the video.
videoSizeSync(filepath: string): { width: number; height: number }
- filepath:
string - Path to the video file.
- returns:
{ width: number; height: number } - An object containing the width and height of the video.
How it works
This module uses ffprobe, part of the FFmpeg suite of tools, to extract the video dimensions. ffprobe is a command-line tool to retrieve media information, which is invoked using Node.js's child_process module.
Dependencies
Ensure that ffprobe is installed and available in your system's PATH. You can check this by running ffprobe -version in your terminal.
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb
Author
Jon Schlinkert
License
Copyright © 2024, Jon Schlinkert.
Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on September 23, 2024.