# get-video-duration

> Get the duration of a video file

Latest version **5.0.0** (published 2025-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-video-duration
pnpm add get-video-duration
yarn add get-video-duration
bun add get-video-duration
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-11-26 |
| First published | 2015-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 139 |
| Author | Lluís Ulzurrun de Asanza Sàez |
| Maintainers | lluis |
| Keywords | video, duration, ffmpeg, ffprobe, typescript |

## Links

- npm: https://www.npmjs.com/package/get-video-duration
- Repository: https://github.com/caffco/get-video-duration
- Homepage: https://github.com/caffco/get-video-duration#readme
- Issues: https://github.com/caffco/get-video-duration/issues
- npm.io page: https://npm.io/package/get-video-duration

## Dependencies (3)

- [execa](https://npm.io/package/execa.md) ^9.6.0
- [is-stream](https://npm.io/package/is-stream.md) ^4.0.1
- [@ffprobe-installer/ffprobe](https://npm.io/package/@ffprobe-installer/ffprobe.md) ^2.1.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2025-11-26
- 4.1.0 — 2022-05-09
- 4.0.0 — 2021-08-13
- 3.1.0 — 2021-05-29
- 3.0.2 — 2020-08-25
- 3.0.2-beta.0 — 2020-08-25
- 3.0.1 — 2020-07-28
- 3.0.1-beta.0 — 2020-07-28
- 3.0.0 — 2020-06-11
- 3.0.0-beta.1 — 2020-05-07
- 2.0.0 — 2020-05-07
- 1.0.3 — 2018-12-16
- 1.0.2 — 2018-11-04
- 1.0.1 — 2018-11-04
- 1.0.0 — 2018-11-04
- … 5 more at https://npm.io/package/get-video-duration/versions

## README

# get-video-duration

[![NPM version][npm-image]][npm-url]
![Build Status](https://github.com/caffco/get-video-duration/workflows/test/badge.svg)
[![Maintainability](https://api.codeclimate.com/v1/badges/d66b9477ad4f7a14b5c9/maintainability)](https://codeclimate.com/github/caffco/get-video-duration/maintainability)
[![Test Coverage](https://codecov.io/gh/caffco/get-video-duration/graph/badge.svg?token=KJKfI5gVoC)](https://codecov.io/gh/caffco/get-video-duration)
[![License][license-image]][license-url]
[![NPM bundle size (minified)][bundle-size-image]][npm-url]
[![Downloads][downloads-image]][downloads-url]

Get the duration of video files/streams with `ffprobe`.

# Supported platforms

Currently this package only supports Linux, Windows 7+, and MacOS 10.9+. **This package does not work in the browser**, iOS or Android.

# Install

```bash
$ npm install --save get-video-duration
```

# Usage

```js
const { getVideoDurationInSeconds } = require('get-video-duration')

// From a local path...
getVideoDurationInSeconds('video.mov').then((duration) => {
  console.log(duration)
})

// From a URL...
getVideoDurationInSeconds(
  'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4'
).then((duration) => {
  console.log(duration)
})

// From a readable stream...

const fs = require('fs')
const stream = fs.createReadStream('video.mov')

getVideoDurationInSeconds(stream).then((duration) => {
  console.log(duration)
})

// If you need to customize the path to ffprobe...
getVideoDurationInSeconds('video.mov', '/path/to/ffprobe').then((duration) => {
  console.log(duration)
})
```

# FAQ

## I get a segmentation fault when trying to download a URL

This is a limitation of the underlying ffprobe binary, which has glibc statically linked and that prevents DNS resolution. Install `nscd` package through your package manager to solve this issue.

# License

MIT. Based on [get-video-dimensions](https://github.com/mgmtio/get-video-dimensions).

[npm-image]: https://img.shields.io/npm/v/get-video-duration.svg
[npm-url]: https://npmjs.org/package/get-video-duration
[bundle-size-image]: https://img.shields.io/bundlephobia/min/get-video-duration.svg
[license-image]: http://img.shields.io/npm/l/get-video-duration.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/get-video-duration.svg
[downloads-url]: https://npmjs.org/package/get-video-duration

---
_Source: https://npm.io/package/get-video-duration · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
