1.0.0 • Published 2 years ago

@numairawan/video-duration v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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!

1.0.0

2 years ago