Skip to content
Dipendra2003Public

About

πŸš€ ClipForge AI is an AI-powered video repurposing platform that transforms long-form videos into engaging short clips using Gemini AI, Whisper, and FFmpeg. 🎬 Features include automatic subtitles, viral moment detection, AI scoring, emotion detection, YouTube publishing, scheduling, cloud storage, and analytics. πŸ“Š

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

15 Commits

Folders and files

Repository files navigation

🎬 ClipForge AI

AI-Powered Video Clipping & Social Media Publishing Platform

Transform long-form videos into viral-ready clips automatically using AI, then publish directly to Instagram, TikTok, YouTube Shorts, and more.


🌟 Key Features

πŸ€– AI-Powered Video Processing

  • Gemini AI Analysis - Automatically identifies viral moments and engaging segments
  • Whisper AI Subtitles - Generates accurate, multi-language subtitles with auto-detection
  • Smart Clipping - FFmpeg creates professional clips with burned-in subtitles
  • Viral Scoring - Each clip receives a viral potential score (0-100%)
  • Emotion Detection - Identifies joy, excitement, surprise, tension, and more
  • Thumbnail Generation - Auto-generates thumbnails for each clip

πŸ“± Social Media Integration

  • Multi-Platform Publishing - Post to Instagram, TikTok, YouTube, Facebook, Twitter/X
  • OAuth Authentication - Secure platform connections via OAuth 2.0
  • Scheduled Posts - Schedule clips for optimal posting times
  • Post Analytics - Track views, likes, comments, and engagement
  • Bulk Publishing - Publish multiple clips across platforms simultaneously

πŸŽ₯ Video Management

  • YouTube Download - Download videos from YouTube/Vimeo/Dailymotion with quality selection (360p to 4K)
  • File Upload - Support for MP4, MOV, AVI, MKV, WEBM formats (up to 500MB)
  • Quality Selection - Choose source video quality during download (affects final clip quality)
  • Smart Processing - FFmpeg-powered clip creation with optimized encoding settings
  • Cloud Storage - Optional Cloudinary integration for video and clip storage
  • Local Storage - Automatic cleanup of processed files to save disk space

πŸ” User Management

  • JWT Authentication - Secure token-based authentication
  • Google OAuth - One-click sign-in with Google
  • Email Verification - Secure account verification system
  • Password Reset - Secure password recovery flow
  • Role-Based Access - User and admin roles with different permissions
  • Multi-Device Sessions - Manage sessions across multiple devices

πŸ“Š Analytics & Dashboard

  • User Dashboard - Comprehensive overview of videos, clips, and posts
  • Platform Analytics - Track performance across all connected platforms
  • Admin Panel - User management, platform monitoring, and system analytics
  • Video Library - Organized library of all processed videos and clips
  • Engagement Metrics - Real-time tracking of post performance

πŸš€ Quick Start

Prerequisites

Before you begin, ensure you have the following installed:

Installation

1. Clone the Repository

git clone <your-repo-url>
cd clipforge

2. Install Dependencies

Backend (Node.js + Python):

# Install Node.js dependencies
cd server
npm install

# Install Python dependencies
pip install -r requirements.txt

Frontend (React):

cd ../client
npm install

3. Environment Configuration

Server Configuration:

cd ../server
cp .env.example .env

Edit server/.env with your credentials:

# =============================================================================
# REQUIRED CONFIGURATION
# =============================================================================

# Server Configuration
PORT=5000
FLASK_PORT=5001
NODE_ENV=development
BACKEND_URL=http://localhost:5000
FRONTEND_URL=http://localhost:5173

# Database (PostgreSQL)
DATABASE_URL=postgresql://postgres:your_password@localhost:5432/clipforge

# JWT Secrets (Generate with: node -e "console.log(require('crypto').randomBytes(64).toString('hex'))")
JWT_SECRET=your-generated-secret-here
JWT_REFRESH_SECRET=your-generated-refresh-secret-here
ACCESS_TOKEN_EXPIRY=24h
REFRESH_TOKEN_EXPIRY=30d

# Email (Gmail - Use App Password, not regular password)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-16-char-app-password
SMTP_FROM=ClipForge <noreply@clipforge.com>

# Google OAuth (Get from: https://console.cloud.google.com/apis/credentials)
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-google-client-secret

# AI Configuration (Get from: https://makersuite.google.com/app/apikey)
GEMINI_API_KEY=your-gemini-api-key
USE_GEMINI=true
GEMINI_MODEL=gemini-2.0-flash-exp

# =============================================================================
# OPTIONAL CONFIGURATION
# =============================================================================

# Cloudinary (Cloud Storage - Get from: https://cloudinary.com)
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
USE_CLOUD_STORAGE=true

# Instagram Graph API (Get from: https://developers.facebook.com/apps/)
INSTAGRAM_APP_ID=your-meta-app-id
INSTAGRAM_APP_SECRET=your-meta-app-secret

# Security Settings
MAX_LOGIN_ATTEMPTS=5
LOCKOUT_DURATION_MINUTES=15
ENABLE_SECURITY_LOGGING=true
ENABLE_RATE_LIMITING=true

# File Upload Settings
MAX_FILE_SIZE=500
ALLOWED_EXTENSIONS=mp4,mov,avi,mkv,webm

# Processing Defaults
DEFAULT_CLIP_DURATION=45
DEFAULT_NUM_CLIPS=5
DEFAULT_VIDEO_QUALITY=720p
DEFAULT_MIN_VIRAL_SCORE=0.5

Client Configuration:

cd ../client
cp .env.example .env.local

Edit client/.env.local:

# API Configuration
VITE_API_URL=http://localhost:5000

# Google OAuth (Must match server configuration)
VITE_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com

4. Database Setup

cd ../server
node migrations/run-migrations.js

This will create all necessary tables and indexes.

5. Start the Application

You'll need 3 terminal windows:

Terminal 1 - Flask Server (Video Processing):

cd server
python app.py
# Runs on http://localhost:5001

Terminal 2 - Node.js Server (API):

cd server
npm start
# Runs on http://localhost:5000

Terminal 3 - React Frontend:

cd client
npm run dev
# Runs on http://localhost:5173

6. Access the Application

Open your browser and navigate to:

http://localhost:5173

πŸ“– Usage Guide

Getting Started

  1. Create an Account

    • Sign up with email or use Google OAuth
    • Verify your email address
  2. Upload or Download a Video

    • Go to /demo page
    • Upload a video file (MP4, MOV, AVI, MKV, WEBM)
    • Or paste a YouTube URL to download
  3. Process with AI

    • Click "Generate Viral Clips with AI"
    • Wait for processing (2-5 minutes for a 5-minute video)
    • First run takes longer (Whisper model download)
  4. View Results

    • Navigate to /dashboard/videos to see your videos
    • Click on a video to view generated clips
    • Each clip shows viral score, emotion, and reason
  5. Download or Publish

    • Download clips directly
    • Or connect social media accounts to publish

Advanced Features

Custom Clip Settings

When processing videos, you can customize:

  • Clip Duration: 15s, 30s, 45s, 60s, or custom (15-90 seconds)
  • Number of Clips: Generate 1-10 clips per video
  • Minimum Viral Score: Filter clips by viral potential (0-100%)
  • Emotion Filter: Focus on specific emotions (joy, excitement, surprise, tension, inspiration)
  • Processing Mode: AI-powered, equal division, or custom time ranges
  • Quality: Choose source video download quality (360p to 4K) - clips inherit this quality
  • Subtitle Language: Auto-detect or specify language (supports 50+ languages via Whisper AI)
  • Skip Subtitles: Fast mode - skip subtitle generation for quicker processing

Social Media Publishing

  1. Connect Platforms

    • Go to /dashboard/settings
    • Click "Connect" for each platform
    • Authorize via OAuth
  2. Schedule Posts

    • Select a clip
    • Choose platforms
    • Set publish time
    • Add captions and hashtags
  3. Track Performance

    • View analytics in /dashboard/analytics
    • Monitor engagement metrics
    • Optimize posting strategy

πŸ—οΈ Architecture

System Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     React Frontend (Vite)                   β”‚
β”‚                      Port 5173                              β”‚
β”‚  - User Interface                                           β”‚
β”‚  - Authentication UI                                        β”‚
β”‚  - Video Management                                         β”‚
β”‚  - Dashboard & Analytics                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β”‚ HTTP/REST API
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Node.js Express API                        β”‚
β”‚                      Port 5000                              β”‚
β”‚  - Authentication & Authorization                           β”‚
β”‚  - User Management                                          β”‚
β”‚  - Video/Clip Metadata                                      β”‚
β”‚  - Platform OAuth                                           β”‚
β”‚  - Post Scheduling                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                   β”‚
         β”‚                                   β”‚ HTTP Requests
         β”‚                                   β”‚
         β”‚                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                          β”‚  Python Flask   β”‚
         β”‚                          β”‚    Port 5001    β”‚
         β”‚                          β”‚                 β”‚
         β”‚                          β”‚ - Video Downloadβ”‚
         β”‚                          β”‚ - AI Processing β”‚
         β”‚                          β”‚ - Clip Creation β”‚
         β”‚                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                   β”‚
         β”‚                                   β”‚
         β–Ό                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   PostgreSQL    β”‚              β”‚  AI Services     β”‚
β”‚    Database     β”‚              β”‚                  β”‚
β”‚                 β”‚              β”‚ - Whisper AI     β”‚
β”‚ - Users         β”‚              β”‚ - Gemini AI      β”‚
β”‚ - Videos        β”‚              β”‚ - FFmpeg         β”‚
β”‚ - Clips         β”‚              β”‚ - yt-dlp         β”‚
β”‚ - Posts         β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ - Platforms     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

Frontend

  • React 19 - UI framework
  • Vite - Build tool and dev server
  • React Router - Client-side routing
  • Tailwind CSS - Utility-first CSS framework
  • Axios - HTTP client

Backend (Node.js)

  • Express.js - Web framework
  • PostgreSQL - Primary database
  • JWT - Authentication tokens
  • Bcrypt - Password hashing
  • Nodemailer - Email service
  • Multer - File upload handling
  • Google OAuth - Social authentication
  • Node-cron - Task scheduling

Backend (Python)

  • Flask - Lightweight web framework
  • OpenAI Whisper - Speech-to-text AI
  • Google Gemini - Video analysis AI
  • FFmpeg - Video processing
  • yt-dlp - YouTube video downloader
  • MoviePy - Video editing library
  • Pillow - Image processing

DevOps & Deployment

  • Railway - Hosting platform
  • Vercel - Frontend deployment option
  • Neon - Serverless PostgreSQL
  • Git - Version control

πŸ“ Project Structure

clipforge/
β”œβ”€β”€ client/                      # React frontend
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   β”‚   β”œβ”€β”€ demo-thumbnail.jpg
β”‚   β”‚   └── demo-video.mp4
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/          # Reusable components
β”‚   β”‚   β”‚   β”œβ”€β”€ DashboardLayout.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ GoogleSignInButton.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Layout.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PostModal.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.jsx
β”‚   β”‚   β”‚   └── Sidebar.jsx
β”‚   β”‚   β”œβ”€β”€ context/             # React context
β”‚   β”‚   β”‚   └── AuthContext.jsx
β”‚   β”‚   β”œβ”€β”€ pages/               # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/           # Admin pages
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Plans.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ PlatformAnalytics.jsx
β”‚   β”‚   β”‚   β”‚   └── Users.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/            # Authentication pages
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ForgotPassword.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ OAuthCallback.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ResetPassword.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Signup.jsx
β”‚   β”‚   β”‚   β”‚   └── VerifyEmail.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ user/            # User dashboard pages
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Analytics.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Clips.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ DashboardOverview.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Scheduled.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Settings.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Subscription.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ VideoDetails.jsx
β”‚   β”‚   β”‚   β”‚   └── Videos.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ About.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Contact.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Demo.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Pricing.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Privacy.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ShareClip.jsx
β”‚   β”‚   β”‚   └── Terms.jsx
β”‚   β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js
β”‚   β”‚   β”‚   β”œβ”€β”€ helpers.js
β”‚   β”‚   β”‚   β”œβ”€β”€ toast.js
β”‚   β”‚   β”‚   └── videoUrl.js
β”‚   β”‚   β”œβ”€β”€ App.jsx              # Main app component
β”‚   β”‚   β”œβ”€β”€ main.jsx             # Entry point
β”‚   β”‚   └── index.css            # Global styles
β”‚   β”œβ”€β”€ .env                     # Environment variables
β”‚   β”œβ”€β”€ index.html               # HTML template
β”‚   β”œβ”€β”€ package.json             # Dependencies
β”‚   β”œβ”€β”€ tailwind.config.js       # Tailwind configuration
β”‚   └── vite.config.js           # Vite configuration
β”‚
β”œβ”€β”€ server/                      # Backend
β”‚   β”œβ”€β”€ config/                  # Configuration
β”‚   β”‚   └── database.js          # Database connection
β”‚   β”œβ”€β”€ controllers/             # Route controllers
β”‚   β”‚   β”œβ”€β”€ aiController.js      # AI processing endpoints
β”‚   β”‚   β”œβ”€β”€ authController.js    # Authentication logic
β”‚   β”‚   β”œβ”€β”€ platformController.js # Social media integration
β”‚   β”‚   └── postController.js    # Post management
β”‚   β”œβ”€β”€ downloads/               # Video storage
β”‚   β”‚   └── clips/               # Generated clips
β”‚   β”œβ”€β”€ logs/                    # Application logs
β”‚   β”‚   β”œβ”€β”€ app.log
β”‚   β”‚   β”œβ”€β”€ error.log
β”‚   β”‚   └── security.log
β”‚   β”œβ”€β”€ middleware/              # Express middleware
β”‚   β”‚   β”œβ”€β”€ authenticateWithQuery.js
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js
β”‚   β”‚   β”œβ”€β”€ csrf.js
β”‚   β”‚   β”œβ”€β”€ rateLimiter.js
β”‚   β”‚   └── validator.js
β”‚   β”œβ”€β”€ migrations/              # Database migrations
β”‚   β”‚   β”œβ”€β”€ run-migrations.js
β”‚   β”‚   β”œβ”€β”€ schema.sql
β”‚   β”‚   └── README.md
β”‚   β”œβ”€β”€ models/                  # Database models
β”‚   β”‚   β”œβ”€β”€ Clip.js
β”‚   β”‚   β”œβ”€β”€ PlatformConnection.js
β”‚   β”‚   β”œβ”€β”€ PublishedPost.js
β”‚   β”‚   β”œβ”€β”€ Session.js
β”‚   β”‚   β”œβ”€β”€ Token.js
β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   └── Video.js
β”‚   β”œβ”€β”€ routes/                  # API routes
β”‚   β”œβ”€β”€ scripts/                 # Utility scripts
β”‚   β”‚   β”œβ”€β”€ checkClipPaths.js
β”‚   β”‚   β”œβ”€β”€ clearVideoData.js
β”‚   β”‚   β”œβ”€β”€ createAdmin.js
β”‚   β”‚   β”œβ”€β”€ resetDatabase.js
β”‚   β”‚   └── verifyAdmin.js
β”‚   β”œβ”€β”€ services/                # Background services
β”‚   β”‚   └── scheduler.js         # Post scheduling
β”‚   β”œβ”€β”€ utils/                   # Utility functions
β”‚   β”‚   β”œβ”€β”€ cleanup.js
β”‚   β”‚   β”œβ”€β”€ email.js
β”‚   β”‚   └── logger.js
β”‚   β”œβ”€β”€ .env                     # Environment variables
β”‚   β”œβ”€β”€ .env.example             # Environment template
β”‚   β”œβ”€β”€ app.py                   # Flask server (Python)
β”‚   β”œβ”€β”€ Server.js                # Express server (Node.js)
β”‚   β”œβ”€β”€ video_processor.py       # Video processing logic
β”‚   β”œβ”€β”€ package.json             # Node dependencies
β”‚   └── requirements.txt         # Python dependencies
β”‚
β”œβ”€β”€ .gitignore                   # Git ignore rules
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ Procfile                     # Railway deployment
β”œβ”€β”€ railway.json                 # Railway configuration
β”œβ”€β”€ nixpacks.toml                # Nixpacks configuration
└── vercel.json                  # Vercel configuration

πŸ”§ Configuration

Environment Variables Reference

Server Environment Variables (server/.env)

Variable Required Default Description
PORT Yes 5000 Node.js server port
FLASK_PORT Yes 5001 Python Flask server port
NODE_ENV Yes development Environment mode (development or production)
BACKEND_URL Yes http://localhost:5000 Backend API URL
FRONTEND_URL Yes http://localhost:5173 Frontend URL (for CORS)
DATABASE_URL Yes - PostgreSQL connection string
JWT_SECRET Yes - Secret for access tokens (64+ chars)
JWT_REFRESH_SECRET Yes - Secret for refresh tokens (64+ chars)
ACCESS_TOKEN_EXPIRY No 24h Access token expiration time
REFRESH_TOKEN_EXPIRY No 30d Refresh token expiration time
SMTP_HOST Yes smtp.gmail.com SMTP server hostname
SMTP_PORT Yes 587 SMTP server port
SMTP_USER Yes - SMTP username/email
SMTP_PASSWORD Yes - SMTP password (Gmail App Password)
SMTP_FROM No ClipForge <noreply@clipforge.com> Email sender name
GOOGLE_CLIENT_ID Yes - Google OAuth client ID
GOOGLE_CLIENT_SECRET Yes - Google OAuth client secret
GEMINI_API_KEY Yes - Google Gemini API key
USE_GEMINI No true Enable/disable Gemini AI
GEMINI_MODEL No gemini-2.0-flash-exp Gemini model version
CLOUDINARY_CLOUD_NAME No - Cloudinary cloud name
CLOUDINARY_API_KEY No - Cloudinary API key
CLOUDINARY_API_SECRET No - Cloudinary API secret
USE_CLOUD_STORAGE No true Enable cloud storage
INSTAGRAM_APP_ID No - Meta/Instagram app ID
INSTAGRAM_APP_SECRET No - Meta/Instagram app secret
MAX_LOGIN_ATTEMPTS No 5 Max failed login attempts
LOCKOUT_DURATION_MINUTES No 15 Account lockout duration
SESSION_CLEANUP_INTERVAL No 24 Session cleanup interval (hours)
ENABLE_SECURITY_LOGGING No true Enable security event logging
ENABLE_RATE_LIMITING No true Enable API rate limiting
MAX_FILE_SIZE No 500 Maximum video upload size (MB)
ALLOWED_EXTENSIONS No mp4,mov,avi,mkv,webm Allowed video file formats
DEFAULT_CLIP_DURATION No 45 Default clip duration (seconds)
DEFAULT_NUM_CLIPS No 5 Default number of clips to generate
DEFAULT_VIDEO_QUALITY No 720p Default video download quality
DEFAULT_MIN_VIRAL_SCORE No 0.5 Default minimum viral score filter

Future Platform Integrations (Optional - Coming Soon):

Variable Description
YOUTUBE_CLIENT_ID YouTube Data API v3 client ID
YOUTUBE_CLIENT_SECRET YouTube Data API v3 client secret
TIKTOK_CLIENT_KEY TikTok API client key
TIKTOK_CLIENT_SECRET TikTok API client secret
TWITTER_API_KEY Twitter/X API key
TWITTER_API_SECRET Twitter/X API secret
TWITTER_BEARER_TOKEN Twitter/X bearer token
FACEBOOK_APP_ID Facebook API app ID
FACEBOOK_APP_SECRET Facebook API app secret

Client Environment Variables (client/.env.local)

Variable Required Default Description
VITE_API_URL Yes http://localhost:5000 Backend API URL
VITE_GOOGLE_CLIENT_ID Yes - Google OAuth client ID (must match server)

Note: Vite only exposes variables prefixed with VITE_ to the frontend.

Getting API Keys & Credentials

1. PostgreSQL Database

Local Setup (Development):

# Install PostgreSQL
# Windows: Download from https://www.postgresql.org/download/windows/
# Mac: brew install postgresql
# Linux: sudo apt-get install postgresql

# Create database
psql -U postgres
CREATE DATABASE clipforge;
\q

# Update DATABASE_URL in .env
DATABASE_URL=postgresql://postgres:your_password@localhost:5432/clipforge

Remote Setup (Production):

  • Neon - Serverless PostgreSQL (Free tier: 0.5 GB)
  • Supabase - PostgreSQL + Auth (Free tier: 500 MB)
  • Railway - PostgreSQL + Hosting (Free tier: $5 credit)

2. JWT Secrets

Generate strong random secrets:

# Run this command twice to generate both secrets
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"

Copy the output to JWT_SECRET and JWT_REFRESH_SECRET in .env

3. Google OAuth

Setup Steps:

  1. Go to Google Cloud Console
  2. Create a new project (or select existing)
  3. Enable Google+ API:
    • Go to "APIs & Services" β†’ "Library"
    • Search for "Google+ API"
    • Click "Enable"
  4. Create OAuth 2.0 credentials:
    • Go to "APIs & Services" β†’ "Credentials"
    • Click "Create Credentials" β†’ "OAuth client ID"
    • Application type: "Web application"
    • Name: "ClipForge AI"
  5. Add authorized redirect URIs:
    http://localhost:5173/auth/callback
    http://localhost:5000/api/auth/google/callback
    https://your-domain.com/auth/callback (for production)
    
  6. Copy Client ID and Client Secret
  7. Add to both server/.env and client/.env.local

4. Gmail App Password (Email Service)

Setup Steps:

  1. Enable 2-Factor Authentication on your Google account:
  2. Generate App Password:
    • Go to App Passwords
    • Select "Mail" and "Other (Custom name)"
    • Name it "ClipForge AI"
    • Click "Generate"
  3. Copy the 16-character password (format: xxxx xxxx xxxx xxxx)
  4. Add to SMTP_PASSWORD in .env (remove spaces)

Alternative Email Providers:

5. Google Gemini AI

Setup Steps:

  1. Go to Google AI Studio
  2. Sign in with your Google account
  3. Click "Get API Key" β†’ "Create API key"
  4. Copy the API key
  5. Add to GEMINI_API_KEY in .env

Free Tier Limits:

  • 60 requests per minute
  • 1,500 requests per day
  • Sufficient for development and small-scale production

6. Cloudinary (Optional - Cloud Storage)

Setup Steps:

  1. Sign up at Cloudinary
  2. Free tier includes:
    • 25 GB storage
    • 25 GB bandwidth/month
    • 25,000 transformations/month
  3. Get credentials from Console:
    • Cloud Name
    • API Key
    • API Secret
  4. Add to .env:
    CLOUDINARY_CLOUD_NAME=your-cloud-name
    CLOUDINARY_API_KEY=your-api-key
    CLOUDINARY_API_SECRET=your-api-secret
    USE_CLOUD_STORAGE=true

Benefits:

  • Automatic file cleanup (saves local disk space)
  • CDN delivery (faster video loading)
  • Video transformations
  • Scalable storage

7. Instagram Graph API (Optional - For Publishing)

Setup Steps:

  1. Go to Meta for Developers
  2. Create new app:
    • Click "Create App"
    • Type: "Business"
    • Name: "ClipForge AI"
  3. Add products:
    • Facebook Login
    • Instagram Graph API
  4. Configure OAuth redirect URI:
    http://localhost:5000/api/platforms/instagram/callback
    https://your-domain.com/api/platforms/instagram/callback
    
  5. Get App ID and App Secret from Settings β†’ Basic
  6. Add to .env:
    INSTAGRAM_APP_ID=your-meta-app-id
    INSTAGRAM_APP_SECRET=your-meta-app-secret

Requirements:

  • User must have Instagram Creator or Business account
  • Instagram account must be connected to a Facebook Page
  • App must be in "Live" mode (requires Meta review for production)

Testing:

  • Use "Development" mode for testing with your own account
  • No review needed for development mode

8. YouTube Data API (Optional - Coming Soon)

Setup Steps:

  1. Go to Google Cloud Console
  2. Enable YouTube Data API v3
  3. Create OAuth 2.0 credentials (same project as Google OAuth)
  4. Add redirect URI:
    http://localhost:5000/api/platforms/youtube/callback
    
  5. Add to .env:
    YOUTUBE_CLIENT_ID=your-youtube-client-id
    YOUTUBE_CLIENT_SECRET=your-youtube-client-secret

Free Tier Limits:

  • 10,000 quota units per day
  • 1 video upload = 1,600 units
  • Sufficient for ~6 uploads per day

9. Other Platforms (Coming Soon)

TikTok API:

Twitter/X API:

Facebook API:

  • Use same Meta app as Instagram
  • Supports video posts to Facebook Pages
  • Requires page management permissions

πŸŽ›οΈ Advanced Configuration

Whisper Model Selection

Edit server/video_processor.py line 27:

# Trade-off: Speed vs Accuracy
model = self.load_whisper_model("base")

# Available Models:
# - tiny: ~1GB RAM, 32x faster, 70% accuracy - Best for testing
# - base: ~1GB RAM, 16x faster, 80% accuracy - Recommended (default)
# - small: ~2GB RAM, 6x faster, 85% accuracy - Good balance
# - medium: ~5GB RAM, 2x faster, 90% accuracy - High accuracy
# - large: ~10GB RAM, 1x speed, 95% accuracy - Best quality (very slow)

# Processing Time Examples (5-minute video):
# - tiny: ~30 seconds
# - base: ~1 minute (default)
# - small: ~2-3 minutes
# - medium: ~5-8 minutes
# - large: ~15-20 minutes

# First run downloads model (~40MB for tiny, ~140MB for base, ~460MB for small)

Recommendation: Use base for production, tiny for development/testing.

Video Quality Settings

The quality selection affects the source video download quality. Clips inherit the quality of the source video.

How it works:

  1. Download Stage - Quality parameter controls yt-dlp download resolution

    • 2160p (4K) β†’ Downloads 4K video β†’ Clips are 4K
    • 720p (HD) β†’ Downloads 720p video β†’ Clips are 720p
    • 360p β†’ Downloads 360p video β†’ Clips are 360p
  2. Clip Creation - FFmpeg uses optimized encoding settings (defined in server/video_processor.py):

# FFmpeg encoding settings for clips
'-c:v', 'libx264',      # H.264 codec
'-c:a', 'aac',          # AAC audio codec
'-preset', 'fast',      # Encoding speed (ultrafast, fast, medium, slow)
'-crf', '23',           # Quality: 0-51 (lower = better quality, larger file)
                        # 23 = good balance between quality and file size
'-avoid_negative_ts', 'make_zero'  # Fix timestamp issues

To customize clip encoding quality, edit server/video_processor.py line 352-356:

  • Lower CRF (18-22) = Higher quality, larger files
  • Higher CRF (24-28) = Lower quality, smaller files
  • Faster preset = Quicker processing, larger files
  • Slower preset = Better compression, smaller files

Clip Generation Settings

Adjust in the frontend or API request:

{
  clipDuration: 45,        // Seconds per clip (15-90s)
  numClips: 5,             // Number of clips to generate (1-10)
  minViralScore: 0.5,      // Minimum viral score (0-1)
  quality: '720p',         // Source video download quality (affects clip quality)
  emotions: ['joy', 'excitement'],  // Filter by emotions
  clipMode: 'ai',          // 'ai' (smart), 'divide' (equal parts), 'range' (custom time)
  startTime: 0,            // Optional: start processing from this time (seconds)
  endTime: 300,            // Optional: end processing at this time (seconds)
  skipSubtitles: false,    // Skip subtitle generation for faster processing
  subtitleLanguage: 'auto' // Auto-detect or specify language code (en, es, fr, etc.)
}

Processing Modes:

  • AI Mode - Gemini AI analyzes content and identifies viral moments
  • Divide Mode - Splits video into equal-duration clips
  • Range Mode - Creates clips from specific time ranges

πŸ“‘ API Documentation

Authentication Endpoints

Register User

POST /api/auth/register
Content-Type: application/json

{
  "name": "Dipendra Kumar",
  "email": "dipendrastm03@gmail.com",
  "password": "SecurePass123!"
}

Login

POST /api/auth/login
Content-Type: application/json

{
  "email": "dipendrastm03@gmail.com",
  "password": "SecurePass123!"
}

Google OAuth

POST /api/auth/google
Content-Type: application/json

{
  "credential": "google-oauth-token"
}

Video Endpoints

Get User Videos

GET /api/videos/my-videos
Authorization: Bearer <access_token>

Get Video Details

GET /api/videos/:videoId
Authorization: Bearer <access_token>

Delete Video

DELETE /api/videos/:videoId
Authorization: Bearer <access_token>

Clip Endpoints

Get User Clips

GET /api/clips/my-clips
Authorization: Bearer <access_token>

Get Clips by Video

GET /api/clips/video/:videoId
Authorization: Bearer <access_token>

Download Clip

GET /api/clips/:clipId/download
Authorization: Bearer <access_token>

Processing Endpoints (Flask)

Download YouTube Video

POST http://localhost:5001/download
Content-Type: application/json

{
  "url": "https://youtube.com/watch?v=...",
  "quality": "720p"
}

Upload Video

POST http://localhost:5001/upload
Content-Type: multipart/form-data

video: <file>

Process Video

POST http://localhost:5001/process
Content-Type: application/json

{
  "videoId": "uuid",
  "userId": "uuid",
  "clipDuration": 45,
  "numClips": 5,
  "quality": "720p",
  "clipMode": "ai",
  "minViralScore": 0.5,
  "emotions": ["joy", "excitement"],
  "skipSubtitles": false,
  "subtitleLanguage": "auto",
  "startTime": 0,
  "endTime": 300
}

Response:

{
  "success": true,
  "videoId": "uuid",
  "status": "completed",
  "videoInfo": {
    "duration": 300,
    "width": 1280,
    "height": 720,
    "fps": 30
  },
  "detectedLanguage": "en",
  "subtitleUrl": "http://localhost:5001/video/uuid.vtt",
  "thumbnailUrl": "http://localhost:5001/video/uuid_thumb.jpg",
  "clips": [
    {
      "clipNumber": 1,
      "title": "Amazing Moment",
      "startTime": 45.5,
      "endTime": 90.5,
      "duration": 45,
      "emotion": "joy",
      "viralScore": 0.85,
      "reason": "High energy and engaging content",
      "clipUrl": "http://localhost:5001/video/uuid_clip_1.mp4"
    }
  ]
}

Get Processing Progress

GET http://localhost:5001/progress/:videoId

πŸ› Troubleshooting

Common Issues

FFmpeg Not Found

Error: FFmpeg not found in PATH

Solution:

  1. Download FFmpeg from ffmpeg.org
  2. Add to system PATH
  3. Verify: ffmpeg -version

Whisper Model Download

Issue: First processing takes 5+ minutes

Explanation: Whisper downloads model on first run (~140MB for base model)

Solution: Wait for initial download, subsequent runs will be faster

Database Connection Error

Error: Connection refused or ECONNREFUSED

Solution:

  1. Verify PostgreSQL is running
  2. Check DATABASE_URL in .env
  3. Test connection: psql -d clipforge

Gemini API Error

Error: API key not valid

Solution:

  1. Verify GEMINI_API_KEY in .env
  2. Check API key at Google AI Studio
  3. Ensure billing is enabled

YouTube Download Fails

Error: Sign in to confirm or Bot detection

Solutions:

  1. Update yt-dlp: pip install --upgrade yt-dlp
  2. Try a different video
  3. Use shorter videos (under 10 minutes)
  4. Consider using Vimeo or Dailymotion instead

Port Already in Use

Error: EADDRINUSE: address already in use

Solution:

# Find process using port
lsof -i :5000  # or :5001, :5173

# Kill process
kill -9 <PID>

Email Not Sending

Error: Invalid login or Authentication failed

Solution:

  1. Use Gmail App Password (not regular password)
  2. Enable 2FA on Google account
  3. Generate app password at myaccount.google.com/apppasswords

Performance Optimization

Slow Processing

  • Use smaller Whisper model (tiny instead of base) in video_processor.py line 27
  • Enable "Skip Subtitles" mode for 50% faster processing (no subtitle generation)
  • Download source video at lower quality (720p or 480p)
  • Process shorter videos (under 10 minutes recommended)
  • Use faster FFmpeg preset (ultrafast or veryfast)
  • Increase server resources (RAM and CPU)
  • First run is always slower (Whisper model download ~140MB)

Large File Sizes

  • Download source video at lower quality (480p or 360p instead of 1080p/4K)
  • Adjust CRF value in video_processor.py (increase from 23 to 26-28 for smaller files)
  • Use faster preset (ultrafast instead of fast) for quicker encoding
  • Enable Cloudinary storage to automatically delete local files after upload

Memory Issues

  • Close other applications
  • Increase Node.js memory: NODE_OPTIONS=--max-old-space-size=4096
  • Process videos sequentially, not in parallel

File Upload Issues

Error: File too large or Invalid file type

Solution:

  1. Check file size (default max: 500MB)
  2. Verify file format (supported: MP4, MOV, AVI, MKV, WEBM)
  3. Adjust limits in .env:
    MAX_FILE_SIZE=500  # in MB
    ALLOWED_EXTENSIONS=mp4,mov,avi,mkv,webm
  4. For larger files:
    • Compress video before upload
    • Use YouTube download instead
    • Enable Cloudinary for better handling

πŸ§ͺ Testing

Run Database Migrations

cd server
node migrations/run-migrations.js

Create Admin User

cd server
node scripts/createAdmin.js

Verify Admin

node scripts/verifyAdmin.js

Clear Video Data

node scripts/clearVideoData.js

Reset Database

node scripts/resetDatabase.js

πŸš€ Deployment

Railway Deployment

  1. Create Railway Account

  2. Create New Project

    • Click "New Project"
    • Select "Deploy from GitHub repo"
    • Connect your repository
  3. Add PostgreSQL

    • Click "New"
    • Select "Database" β†’ "PostgreSQL"
    • Copy DATABASE_URL
  4. Configure Environment Variables

    • Go to project settings
    • Add all variables from .env.example
    • Set NODE_ENV=production
  5. Deploy

    • Railway auto-deploys on git push
    • Monitor logs in dashboard

Vercel Deployment (Frontend Only)

  1. Install Vercel CLI
npm install -g vercel
  1. Deploy
cd client
vercel
  1. Configure Environment
    • Add VITE_API_URL in Vercel dashboard
    • Point to your Railway backend URL

Environment Variables for Production

NODE_ENV=production
FRONTEND_URL=https://your-domain.com
DATABASE_URL=postgresql://...  # From Railway/Neon
JWT_SECRET=<strong-random-string>
JWT_REFRESH_SECRET=<strong-random-string>
# ... other variables

🀝 Contributing

We welcome contributions! Here's how you can help:

Reporting Bugs

  1. Check existing issues
  2. Create detailed bug report
  3. Include steps to reproduce
  4. Add screenshots if applicable

Feature Requests

  1. Open an issue with [Feature Request] tag
  2. Describe the feature
  3. Explain use case
  4. Discuss implementation

Pull Requests

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

Development Guidelines

  • Follow existing code style
  • Write clear commit messages
  • Add comments for complex logic
  • Test thoroughly before submitting
  • Update documentation as needed

πŸ“„ License

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


πŸ™ Acknowledgments

Technologies

Inspiration

Built for content creators who want to maximize their reach across social media platforms with AI-powered automation.


πŸ“ž Support

Documentation

Community

Contact


πŸ—ΊοΈ Roadmap

Current Version (v1.0)

  • βœ… AI-powered video clipping
  • βœ… Multi-platform authentication
  • βœ… Social media OAuth integration
  • βœ… Post scheduling
  • βœ… Analytics dashboard
  • βœ… Admin panel

Upcoming Features (v1.1)

  • πŸ”„ Batch video processing
  • πŸ”„ Advanced subtitle customization
  • πŸ”„ More platform integrations (LinkedIn, Pinterest)
  • πŸ”„ Team collaboration features
  • πŸ”„ API for third-party integrations

Future Plans (v2.0)

  • πŸ“‹ AI-generated captions and hashtags
  • πŸ“‹ A/B testing for posts
  • πŸ“‹ Advanced analytics with ML insights
  • πŸ“‹ Mobile app (iOS/Android)
  • πŸ“‹ White-label solution

πŸ“Š Stats

  • Languages: JavaScript, Python, SQL
  • Frameworks: React, Express, Flask
  • AI Models: Whisper, Gemini
  • Database: PostgreSQL
  • Lines of Code: ~15,000+
  • Files: 100+

Made with ❀️ for content creators worldwide

Transform your long-form content into viral clips with the power of AI


πŸ”— Quick Links

About

πŸš€ ClipForge AI is an AI-powered video repurposing platform that transforms long-form videos into engaging short clips using Gemini AI, Whisper, and FFmpeg. 🎬 Features include automatic subtitles, viral moment detection, AI scoring, emotion detection, YouTube publishing, scheduling, cloud storage, and analytics. πŸ“Š

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages

⌂ 捒网址