Socket
Book a DemoInstallSign in
Socket

video-size

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

video-size

Get the width and height of a video using ffprobe.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

video-size NPM version NPM monthly downloads NPM total downloads

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)) // { width: 1920, height: 1080 }
  .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); // { width: 1920, height: 1080 }

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#dev verb-generate-readme && 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.

Keywords

dimensions

FAQs

Package last updated on 23 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts