@numairawan/video-duration

1.0.0 • Public • Published

video-duration

Total Hits Downloads Version License


video-duration 📺 Get video duration from any URL and video object in Node.js and the browser without ffmpeg/ffprobe.

📦 Installation

Node.js

You can install the package using npm:

npm i @numairawan/video-duration

Usage in nodeJS

const { videoDuration } = require("@numairawan/video-duration");

// Using a video URL
const videoUrl = "https://example.com/sample.mp4";
videoDuration(videoUrl)
  .then(duration => {
    console.log(`Video duration: `, duration);
  })
  .catch(error => {
    console.error(error);
  });

// Using a local video file (Node.js)
const localVideoPath = "path/to/local/video.mp4";
videoDuration(localVideoPath)
  .then(duration => {
    console.log(`Video duration: `, duration);
  })
  .catch(error => {
    console.error(error);
  });

Browser

You can use the package in the browser by including it directly via a CDN. It's lightweight, only 1KB in size.

<script src="https://cdn.jsdelivr.net/npm/@numairawan/video-duration/dist/index.min.js"></script>

Usage in browser

// VideoDuration class
const videoDuration = new VideoDuration();

// Using a video URL
const videoUrl = "https://example.com/sample.mp4";
videoDuration.analyze(videoUrl)
  .then(duration => {
    console.log(`Video duration: `, duration);
  })
  .catch(error => {
    console.error(error);
  });

// Using a local video file (Node.js)
const localVideoPath = "path/to/local/video.mp4";
videoDuration.analyze(localVideoPath)
  .then(duration => {
    console.log(`Video duration: `, duration);
  })
  .catch(error => {
    console.error(error);
  });

Contributing

Contributions are welcome! Feel free to fork the repository and submit pull requests as well.

License

This project is licensed under the MIT license.

Connect with Me

Feel free to reach out to me for any project-related queries or collaborations. I'm always happy to connect and discuss ideas!

Readme

Keywords

Package Sidebar

Install

npm i @numairawan/video-duration

Weekly Downloads

75

Version

1.0.0

License

MIT

Unpacked Size

3.27 MB

Total Files

12

Last publish

Collaborators

  • numairawan