Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including get-video-duration with all npm packages installed. Try it out:

var getVideoDuration = require("get-video-duration")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

get-video-duration v3.0.2

Get the duration of a video file

get-video-duration

NPM version Build status Test coverage Dependency Status License NPM bundle size (minified) Downloads

Get the duration of video files/streams with ffprobe.

Install

$ npm install --save get-video-duration

Usage

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)
})

License

MIT. Based on get-video-dimensions.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free