Skip to content

Repository files navigation

🎥 Video Duration Calculator

Fast, privacy-first video duration calculation using a custom MP4 binary parser, browser metadata, and an optional AI fallback.

Fast • Browser-Based • Privacy First • Open Source

FeaturesPreviewHow it WorksInstallationPrivacy


📸 Preview

demo dashbaord


✨ Features

Feature Description
⚡ Fast MP4 Binary Parser Reads MP4 metadata directly without decoding the video.
📁 Batch Processing Process multiple videos with drag & drop support.
🎬 Multi-stage Detection Binary parser → Browser Metadata → AI Fallback.
📊 Duration Statistics Calculate total and average duration instantly.
🤖 Optional AI Fallback Uses Gemini only when local detection fails.
🔒 Privacy First Files remain on your device whenever possible.
💻 Browser Based No installation required.

Why?

Most online video duration calculators require uploading videos to a server.

This project processes videos locally whenever possible using a custom MP4 binary parser.

This makes duration detection significantly faster while keeping your videos private.


🚀 How it Works

The application follows a three-stage detection pipeline.

       [ Upload Video Files ]
                 │
                 ▼
    ┌─────────────────────────┐
    │  1. Binary MP4 Parser   │ ──(Success)──► [ Display Results ✅ ]
    └─────────────────────────┘
                 │
             (Failed)
                 │
                 ▼
    ┌─────────────────────────┐
    │ 2. HTML5 Metadata API   │ ──(Success)──► [ Display Results ✅ ]
    └─────────────────────────┘
                 │
             (Failed)
                 │
                 ▼
    ┌─────────────────────────┐
    │ 3. Gemini AI Fallback   │ ──(Success)──► [ Display Results ✅ ]
    └─────────────────────────┘

The majority of MP4 files are processed locally using the custom binary parser, making the application extremely fast while keeping videos on your device.


🛠 Technology Stack

Category Technologies
Frontend React
Language TypeScript
Build Tool Vite
Local Processing HTML5 Video API
Binary Parsing Custom MP4 Parser
AI (Optional) Google Gemini

📂 Project Structure

src/
│
├── components/
│
├── utils/
│   ├── mp4Parser.ts
│   ├── videoProcessor.ts
│   └── timeFormatter.ts
│
├── types.ts
├── App.tsx
└── main.tsx

📦 Installation

Clone the repository

git clone https://github.com/lab1207/Video-Duration-Calculator.git

Enter the project

cd Video-Duration-Calculator

Install dependencies

npm install

Create a .env file

GEMINI_API_KEY=YOUR_GEMINI_API_KEY

Get your free API key from Google AI Studio:

https://aistudio.google.com/app/apikey

Run the development server

npm run dev

Build for production

npm run build

Preview production build

npm run preview

🔑 Environment Variables

Variable Required Description
GEMINI_API_KEY Optional Enables the AI fallback used only when local video duration detection fails.

🔒 Privacy

This application is designed to process videos locally whenever possible.

Processing order:

  1. Custom MP4 Binary Parser
  2. Browser Metadata
  3. Google Gemini AI (Optional)

If you do not provide a GEMINI_API_KEY, the application will continue working normally for supported video formats. Only the optional AI fallback will be unavailable.


🌍 Browser Support

  • ✅ Chrome
  • ✅ Edge
  • ✅ Firefox
  • ✅ Safari

🗺 Roadmap

  • Folder Upload
  • Recursive Directory Scanning
  • Parallel Processing Queue
  • CSV Export
  • Excel Export
  • JSON Export
  • Additional Video Format Support
  • Progress Indicators
  • Offline Mode (PWA)
  • File Search & Filtering

🤝 Contributing

Contributions, issues, and feature requests are welcome.

Feel free to open an issue or submit a pull request.


📄 License

This project is licensed under the MIT License.

About

Fast, privacy-first video duration calculator using MP4 binary parsing, browser metadata, and optional Gemini AI fallback.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages