Skip to content

Latest commit

Β 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 AV Utility Platform

A modern, cloud-native audio/video processing platform built with React and Node.js, featuring direct Cloudflare R2 integration for cost-effective, scalable media processing.

✨ Features

Audio Processing

  • 🎡 Extract Audio Tracks - Extract multiple audio tracks from videos with batch processing
  • πŸ”„ Audio Format Conversion - Convert between MP3, WAV, M4A, AAC, OGG, FLAC
  • πŸ—œοΈ Audio Compression - Reduce file sizes with configurable bitrate settings

Video Processing

  • πŸ“Ή Video Compression - Compress videos with H.264/H.265 codecs
  • 🎯 Resolution Scaling - Downscale to 1080p, 720p, or 480p
  • πŸ”” Push Notifications - Get notified when processing completes

Platform Features

  • ☁️ Cloud-Native Architecture - Direct browser-to-R2 uploads/downloads
  • πŸ“Š Real-Time Progress - Live FFmpeg progress via Server-Sent Events (SSE)
  • 🚦 Job Queue System - Automatic queueing with position tracking
  • πŸ”„ Batch Processing - Process multiple tracks/files sequentially
  • πŸ’Ύ Zero Disk Usage - Fully R2-based, no local file storage
  • 🎨 Modern UI - Beautiful, responsive React interface

πŸ—οΈ Architecture

Old Architecture (Multer-based) ❌

Browser β†’ Backend (Upload) β†’ Disk β†’ FFmpeg β†’ Disk β†’ Backend β†’ Browser (Download)
Cost: ~$18/month for 1000 videos
Bottleneck: Backend bandwidth, disk I/O

New Architecture (R2-based) βœ…

Browser β†’ R2 (Direct Upload)
Backend β†’ R2 (Download) β†’ FFmpeg β†’ R2 (Upload)
R2 β†’ Browser (Direct Download)

Cost: ~$32/month for 1000 videos (with backend processing egress)
Benefits: 3x capacity on free tier, better scalability

πŸ› οΈ Tech Stack

Frontend

  • βš›οΈ React 18
  • 🎨 TailwindCSS (custom design system)
  • πŸ”” Web Push API
  • πŸ“‘ Server-Sent Events (SSE)
  • πŸ“¦ Vite

Backend

  • 🟒 Node.js + Express
  • 🎬 FFmpeg (static binaries)
  • ☁️ Cloudflare R2 (AWS S3-compatible)
  • πŸ—„οΈ MongoDB
  • πŸ”” Web Push (VAPID)

Infrastructure

  • πŸ”₯ Firebase App Hosting (Backend)
  • πŸ”₯ Firebase Hosting (Frontend)
  • ☁️ Cloudflare R2 (Object Storage)

πŸ“¦ Installation

Prerequisites

  • Node.js 18+
  • MongoDB instance
  • Cloudflare R2 account
  • Firebase account (for deployment)

Setup

  1. Clone the repository
git clone https://github.com/yourusername/av-utility-platform.git
cd av-utility-platform
  1. Install dependencies

Frontend:

cd avutility
npm install

Backend:

cd server
npm install
  1. Configure Environment Variables

Create server/.env:

# MongoDB
MONGODB_URI=mongodb://localhost:27017/avutility

# Cloudflare R2
R2_ACCOUNT_ID=your_cloudflare_account_id
R2_ACCESS_KEY_ID=your_r2_access_key_id
R2_SECRET_ACCESS_KEY=your_r2_secret_access_key
R2_BUCKET_NAME=av-utility-media
R2_PUBLIC_URL=https://your-r2-bucket.r2.dev

# Job Configuration
MAX_CONCURRENT_JOBS=2
JOB_TIMEOUT_MINUTES=30
SIGNED_URL_EXPIRY=300

# Web Push (Optional)
VAPID_PUBLIC_KEY=your_vapid_public_key
VAPID_PRIVATE_KEY=your_vapid_private_key
VAPID_SUBJECT=mailto:your@email.com

# Server
PORT=3000

Create avutility/.env:

VITE_API_BASE_URL=http://localhost:3000
  1. Configure Cloudflare R2

Follow the detailed setup guide: server/R2_SETUP_GUIDE.md

πŸš€ Running Locally

Development Mode

Terminal 1 (Backend):

cd server
npm run dev
# or
nodemon server.js

Terminal 2 (Frontend):

cd avutility
npm run dev

Access the app at http://localhost:5173

Production Build

Frontend:

cd avutility
npm run build

Backend:

cd server
npm start

πŸ§ͺ Testing

The project includes comprehensive testing tools:

cd server

# Test R2 service integration
node tests/test-r2-service.js

# Test API endpoints
node tests/test-api-endpoints.js

# Open interactive web test client
# Then navigate to: http://localhost:3000/tests/test-client.html

See server/TESTING_GUIDE.md for detailed testing instructions.

πŸ“š API Documentation

Complete API documentation: server/API_DOCUMENTATION.md

Key Endpoints

  • POST /api/upload-url - Generate signed upload URL
  • POST /api/start-job - Start processing job
  • GET /api/job-status/:jobId - SSE progress stream
  • GET /api/download-url/:jobId - Generate signed download URL
  • POST /api/cleanup/:jobId - Cleanup job files

🎯 Features in Detail

Multi-Track Batch Extraction

Extract multiple audio tracks from a single video automatically:

  1. Upload video β†’ Analyze
  2. Select multiple tracks (e.g., Track 1, 3, 5)
  3. Click "Extract X Selected Tracks"
  4. Watch automatic sequential processing
  5. Download all files individually or batch download

Queue System

When concurrent job limit is reached:

  • Shows queue position (e.g., "Position #3")
  • Displays estimated wait time
  • Auto-starts when slot available
  • Smooth transition from queued β†’ processing

On-Demand Download URLs

Download URLs are generated fresh on-click to prevent expiration:

  • 5-minute expiry on signed URLs
  • Regenerated when user clicks download
  • No expiration possible
  • Can wait hours between extraction and download

πŸ’° Cost Analysis

Firebase Free Tier Limits

  • Bandwidth: 10 GiB/month
  • Capacity: ~196 videos/month (100MB videos β†’ 50MB outputs)

R2 Free Tier

  • Storage: 10 GB
  • Operations: 1M Class A, 10M Class B per month
  • Egress: 10 GB/month to internet (free within Cloudflare)

Monthly Costs (Beyond Free Tier)

  • R2 egress: $0.36/GB (backend processing)
  • Firebase egress: $0.12/GB (output to R2)
  • Total: ~$0.048 per 100MB video

vs Old Architecture

  • Old: 67 videos/month max (exceeded bandwidth at 10GB)
  • New: 196 videos/month (3x capacity improvement)

πŸš€ Deployment

Firebase Deployment

  1. Install Firebase CLI
npm install -g firebase-tools
firebase login
  1. Initialize Firebase
firebase init
# Select: Hosting, App Hosting
  1. Deploy
# Deploy frontend
cd avutility
npm run build
firebase deploy --only hosting

# Deploy backend
cd server
firebase deploy --only apphosting

See server/API_DOCUMENTATION.md#deployment for detailed deployment guide.

πŸ—‚οΈ Project Structure

av-utility-platform/
β”œβ”€β”€ avutility/              # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # Reusable components (QueueStatus, etc.)
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom hooks (useR2Upload, useJobProcessing)
β”‚   β”‚   β”œβ”€β”€ pages/          # Page components
β”‚   β”‚   β”‚   └── tools/      # Processing tools (ExtractAudio, CompressVideo, etc.)
β”‚   β”‚   └── utils/          # Utilities (r2ApiService, etc.)
β”‚   └── public/
β”‚
β”œβ”€β”€ server/                 # Node.js backend
β”‚   β”œβ”€β”€ controllers/        # Route handlers (mediaController, etc.)
β”‚   β”œβ”€β”€ services/           # Business logic (r2Service, ffmpegService, jobService)
β”‚   β”œβ”€β”€ routes/             # API routes
β”‚   β”œβ”€β”€ utils/              # Utilities (pushService, cleanupUtil)
β”‚   β”œβ”€β”€ tests/              # Test scripts and client
β”‚   └── temp/               # Temporary FFmpeg processing (auto-cleaned)
β”‚
β”œβ”€β”€ .env.example            # Environment template
β”œβ”€β”€ API_DOCUMENTATION.md    # Complete API docs
β”œβ”€β”€ R2_SETUP_GUIDE.md       # R2 configuration guide
└── TESTING_GUIDE.md        # Testing instructions

πŸ”’ Security

  • βœ… Private R2 bucket (no public access)
  • βœ… Short-lived signed URLs (5 min expiry)
  • βœ… CORS configured for specific origins
  • βœ… Input validation on all endpoints
  • βœ… Job timeout limits (30 min default)
  • βœ… Automatic cleanup of processed files

πŸ›£οΈ Roadmap

  • Cloudflare Workers migration (zero egress costs)
  • User authentication and accounts
  • File history and management
  • Additional video formats (AVI, MKV, WebM)
  • Thumbnail generation
  • Video trimming/splitting
  • Subtitle extraction
  • Mobile app (React Native)

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

For issues, questions, or feature requests:


Made with ❀️ using React, Node.js, and Cloudflare R2

About

A lightweight full-stack media processing platform built to compress, convert, and transform audio and video files seamlessly across modern formats.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages