Get the width and height of a video.
Install with npm:
$ npm install --save video-sizeGet the width, height, and display orientation of a video file using ffprobe.
npm install video-size
pnpm add video-size
yarn add video-sizevideo-size shells out to ffprobe, so FFmpeg needs to be installed and ffprobe needs to be available on your PATH.
import videoSize from 'video-size';
const dimensions = await videoSize('video.mp4');
console.log(dimensions);
// { width: 1280, height: 720, orientation: 'landscape' }import videoSize from 'video-size';
const dimensions = videoSize.sync('video.mp4');
console.log(dimensions);
// { width: 1280, height: 720, orientation: 'landscape' }The sync function is also available as a named export:
import { sync as videoSizeSync } from 'video-size';
const dimensions = videoSizeSync('video.mp4');Returns a promise for the dimensions of the first video stream in filepath.
const dimensions = await videoSize('video.mp4');Returns the dimensions of the first video stream in filepath.
const dimensions = videoSize.sync('video.mp4');Returns true when filepath has a supported video extension.
import { isVideoFile } from 'video-size';
isVideoFile('clip.mp4');
// true
isVideoFile('notes.txt');
// falseA Set of supported video extensions, including mp4, mov, m4v, mkv, mpeg, mpg, webm, avi, flv, 3gp, 3g2, ts, m2t, m2ts, and mts.
import { VIDEO_EXTS } from 'video-size';
VIDEO_EXTS.has('mp4');
// trueBoth async and sync APIs return a VideoDimensions object:
interface VideoDimensions {
width: number;
height: number;
orientation: 'landscape' | 'portrait' | null;
}width and height are the encoded dimensions reported by ffprobe.
orientation is based on the display dimensions. Rotation metadata is respected, so a rotated video can be reported as portrait even when the encoded width is greater than the encoded height. Square videos return null.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
$ npm install -g verb verb-generate-readme && verbInstall dev dependencies:
$ npm install -d && npm testJon Schlinkert
Copyright © 2026, Jon Schlinkert. MIT
This file was generated by verb-generate-readme, v0.1.31, on May 16, 2026.