reafactor readme added instructions and texts

This commit is contained in:
juancarlos.cavero 2025-12-20 04:59:38 +01:00
parent c40e5aaa1d
commit d60c376013
4 changed files with 275 additions and 242 deletions

119
README.md
View file

@ -1,108 +1,103 @@
# OpenShorts 🚀🎬 # OpenShorts.app 🚀🎬
OpenShorts is an open-source tool designed to automate the creation of viral vertical content. It transforms long YouTube videos or local files into multiple short clips optimized for **TikTok**, **Instagram Reels**, and **YouTube Shorts**. OpenShorts is an all-in-one open-source solution to automate the creation and distribution of viral vertical content. It transforms long YouTube videos or local files into high-potential short clips optimized for **TikTok**, **Instagram Reels**, and **YouTube Shorts**.
![OpenShorts Demo](https://github.com/kamilstanuch/Autocrop-vertical/blob/main/churchil_queen_vertical_short.gif?raw=true) ![OpenShorts Demo](https://github.com/kamilstanuch/Autocrop-vertical/blob/main/churchil_queen_vertical_short.gif?raw=true)
*(The demo shows the smart crop process, now powered by AI clip selection)*
--- ---
## ✨ Key Features ## ✨ Key Features
OpenShorts goes beyond simple cropping. It combines the power of Artificial Intelligence to understand your video and extract pure gold: OpenShorts leverages state-of-the-art AI to handle the entire content lifecycle:
1. **🧠 AI Virality Detection (Gemini + Whisper):** 1. **🧠 Viral Moment Detection:**
* Automatically transcribes video audio using **OpenAI Whisper**. * **Faster-Whisper**: High-speed, CPU-optimized transcription and word-level timestamps.
* Analyzes content with **Google Gemini 1.5 Flash** to identify moments with the highest viral potential (hooks, jokes, impactful conclusions). * **Google Gemini 2.0 Flash**: Advanced AI analysis to identify the 3-15 most viral moments based on hooks and engagement potential.
* Generates SEO-optimized titles and descriptions for social media. * **Automatic Copywriting**: Generates SEO-optimized titles and descriptions for all platforms.
2. **✂️ Smart Cropping (Auto-Crop):** 2. **✂️ Smart AI Cropping:**
* Detects people and faces using **YOLOv8** and **OpenCV**. * **YOLOv8 + OpenCV**: intelligent subject tracking that keeps people/faces centered in the 9:16 frame.
* Keeps the subject always in the center of the vertical frame (9:16). * **Dynamic Letterboxing**: Automatically handles multiple subjects to preserve context when they are far apart.
* Automatically applies *letterboxing* if multiple people are detected far apart to preserve context.
3. **⚡ Fast Processing:** 3. **📲 Direct Social posting:**
* Downloads YouTube videos in the best compatible quality. * **Upload-Post Integration**: Share your generated clips directly to TikTok, Instagram, and YouTube with a single click.
* Performs precise cuts based on exact timestamps dictated by AI. * **Profile Selector**: Manage multiple social accounts easily through the dashboard.
* Uses FFmpeg for efficient rendering.
4. **🎨 Modern Web Dashboard:**
* **Real-time Progress**: Watch clips appear as they are generated with a live results feed.
* **Log Streaming**: Follow the technical process with real-time log updates.
* **Responsive Design**: A premium, dark-mode glassmorphism interface.
--- ---
## 🛠️ Requirements ## 🛠️ Requirements
* **Docker** and **Docker Compose** installed on your machine. * **Docker & Docker Compose**.
* A **Google Gemini API Key** (Free at [Google AI Studio](https://aistudio.google.com/app/apikey)). * **Google Gemini API Key** ([Get it for free here](https://aistudio.google.com/app/apikey)).
* **Upload-Post API Key** (Optional, for direct social posting).
### 📲 Social Media Setup (Upload-Post)
To enable direct posting, follow these steps:
1. **Login/Register**: [app.upload-post.com/login](https://app.upload-post.com/login)
2. **Create Profile**: Go to [Manage Users](https://app.upload-post.com/manage-users) and create a user profile.
3. **Connect Accounts**: In the same section, connect your TikTok, Instagram, or YouTube accounts to that profile.
4. **Get API Key**: Navigate to [API Keys](https://app.upload-post.com/api-keys) and generate your key.
5. **Use in OpenShorts**: Paste the API Key and select your Profile in the dashboard.
![Upload-Post Setup Guide](file:///Users/juancarlos.cavero/.gemini/antigravity/brain/d72ee29e-ee3b-45f0-b00b-fe2d705bb56f/uploaded_image_1766201890395.png)
--- ---
## 🚀 Quick Start ## 🚀 Getting Started
The easiest way to run OpenShorts is using Docker Compose.
### 1. Setup ### 1. Setup
Clone the repository and configure your API key:
```bash ```bash
# 1. Clone the repo
git clone https://github.com/your-username/OpenShorts.git git clone https://github.com/your-username/OpenShorts.git
cd OpenShorts cd OpenShorts
# 2. Configure environment variables
cp .env.example .env
# 3. Edit .env and paste your GEMINI_API_KEY (must start with 'AIza...')
nano .env
``` ```
### 2. Run with Docker ### 2. Launch the Application
No need to install Python or libraries on your system, everything runs in a container.
**From a YouTube video:**
The system will download the video, search for viral clips, and deliver multiple vertical files ready for upload.
```bash ```bash
docker compose run --rm autocrop -u "https://www.youtube.com/watch?v=YOUR_VIDEO_ID" docker compose up --build
``` ```
**From a local file:** ### 3. Access the Dashboard
Place your video in the `videos/input/` folder. Open your browser and navigate to:
**`http://localhost:5173`**
```bash 1. Enter your **Gemini API Key**.
docker compose run --rm autocrop -i /videos/input/my_video.mp4 2. (Optional) Enter your **Upload-Post API Key** to enable social sharing.
``` 3. Paste a **YouTube URL** or **Upload a Video**.
4. Click **"Generate Clips"** and watch the magic happen!
### 3. Results
Generated clips will appear in the `videos/` folder (or wherever you specified). Additionally, you'll find a `.json` file with the viral titles and descriptions suggested by AI for each clip.
--- ---
## ⚙️ Advanced Options ## 🏗️ Technical Pipeline
| Flag | Description | 1. **Ingestion**: Downloads YouTube videos via `yt-dlp` or handles local uploads.
| :--- | :--- | 2. **Transcription**: `faster-whisper` converts audio to text in seconds.
| `-u`, `--url` | YouTube URL to download and process. | 3. **AI Intelligence**: Gemini reads the transcript and selects periods of high interest.
| `-i`, `--input` | Path to the local video file (inside the container). | 4. **Extraction**: FFmpeg precisely cuts the selected segments.
| `-o`, `--output` | Output directory or specific filename. | 5. **Reframing**: AI-powered visual tracking crops clips to vertical format.
| `--keep-original` | Keeps the original downloaded video after processing. | 6. **Distribution**: One-click posting via Upload-Post API.
| `--skip-analysis` | **Classic Mode:** Skips Gemini/Whisper AI and converts the ENTIRE video to flat vertical format. |
--- ---
## 🏗️ How It Works (Pipeline) ## 🔒 Security & Performance
1. **Download/Input**: Gets the source video in high quality. * **Non-Root Execution**: Containers run as a dedicated `appuser` for security.
2. **Transcription (Whisper)**: Converts all audio to text with word-level timestamps. * **Concurrency Control**: Configurable job queue (`MAX_CONCURRENT_JOBS`).
3. **Analysis (Gemini)**: AI reads the transcript and identifies the 3-15 most interesting segments, returning exact timestamps and metadata. * **Auto-Cleanup**: Automatic purging of old jobs and temporary files.
4. **Extraction**: Selected segments are cut from the original video. * **File Limits**: Built-in protection against oversized uploads.
5. **Vertical Conversion**: Each clip goes through the visual detection engine (YOLO) to dynamically reframe the action to 9:16 format.
--- ---
## 🤝 Contributions ## 🤝 Contributions
Contributions are welcome! If you have ideas to improve clip detection or cropping, feel free to open a PR. Contributions are welcome! Whether it's adding new AI models or improving the cropping engine, feel free to open a PR.
## 📄 License ## 📄 License
MIT License. Feel free to use it for your personal or commercial projects. MIT License. OpenShorts is yours to use, modify, and scale.

2
app.py
View file

@ -23,7 +23,7 @@ os.makedirs(OUTPUT_DIR, exist_ok=True)
# Configuration # Configuration
# Default to 1 if not set, but user can set higher for powerful servers # Default to 1 if not set, but user can set higher for powerful servers
MAX_CONCURRENT_JOBS = int(os.environ.get("MAX_CONCURRENT_JOBS", "1")) MAX_CONCURRENT_JOBS = int(os.environ.get("MAX_CONCURRENT_JOBS", "5"))
MAX_FILE_SIZE_MB = 500 # 500 MB limit MAX_FILE_SIZE_MB = 500 # 500 MB limit
JOB_RETENTION_SECONDS = 3600 # 1 hour retention JOB_RETENTION_SECONDS = 3600 # 1 hour retention

View file

@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Upload, FileVideo, Sparkles, Youtube, Instagram, Share2, LogOut, ChevronDown, Check, Activity, LayoutDashboard, Settings, PlusCircle, History, Menu, X, Terminal } from 'lucide-react'; import { Upload, FileVideo, Sparkles, Youtube, Instagram, Share2, LogOut, ChevronDown, Check, Activity, LayoutDashboard, Settings, PlusCircle, History, Menu, X, Terminal, Shield } from 'lucide-react';
import KeyInput from './components/KeyInput'; import KeyInput from './components/KeyInput';
import MediaInput from './components/MediaInput'; import MediaInput from './components/MediaInput';
import ResultCard from './components/ResultCard'; import ResultCard from './components/ResultCard';
@ -9,6 +9,7 @@ import { getApiUrl } from './config';
// Enhanced "Encryption" using XOR + Base64 with a Salt // Enhanced "Encryption" using XOR + Base64 with a Salt
// This is better than plain Base64 but still client-side. // This is better than plain Base64 but still client-side.
const SECRET_KEY = import.meta.env.VITE_ENCRYPTION_KEY || "OpenShorts-Secret-Key-2025-V1"; const SECRET_KEY = import.meta.env.VITE_ENCRYPTION_KEY || "OpenShorts-Secret-Key-2025-V1";
const ENCRYPTION_PREFIX = "ENC:";
const encrypt = (text) => { const encrypt = (text) => {
if (!text) return ''; if (!text) return '';
@ -16,7 +17,7 @@ const encrypt = (text) => {
const xor = text.split('').map((c, i) => const xor = text.split('').map((c, i) =>
String.fromCharCode(c.charCodeAt(0) ^ SECRET_KEY.charCodeAt(i % SECRET_KEY.length)) String.fromCharCode(c.charCodeAt(0) ^ SECRET_KEY.charCodeAt(i % SECRET_KEY.length))
).join(''); ).join('');
return btoa(xor); return ENCRYPTION_PREFIX + btoa(xor);
} catch (e) { } catch (e) {
console.error("Encryption failed", e); console.error("Encryption failed", e);
return text; return text;
@ -25,17 +26,23 @@ const encrypt = (text) => {
const decrypt = (text) => { const decrypt = (text) => {
if (!text) return ''; if (!text) return '';
try { if (text.startsWith(ENCRYPTION_PREFIX)) {
// Check if it's plain base64 or our custom XOR (simple try) try {
const xor = atob(text); const raw = text.slice(ENCRYPTION_PREFIX.length);
const result = xor.split('').map((c, i) => // Check if it's plain base64 or our custom XOR (simple try)
String.fromCharCode(c.charCodeAt(0) ^ SECRET_KEY.charCodeAt(i % SECRET_KEY.length)) const xor = atob(raw);
).join(''); const result = xor.split('').map((c, i) =>
return result; String.fromCharCode(c.charCodeAt(0) ^ SECRET_KEY.charCodeAt(i % SECRET_KEY.length))
} catch (e) { ).join('');
// Fallback if decryption fails (might be old plain text) return result;
return text; } catch (e) {
// Fallback if decryption fails (might be old plain text)
return '';
}
} }
// Backward compatibility: If no prefix, assume old plain text (or return empty if you want to force re-login)
// For migration: Return text as is, so it populates the field, and next save will encrypt it.
return text;
}; };
// Simple TikTok icon sine Lucide might not have it or it varies // Simple TikTok icon sine Lucide might not have it or it varies
@ -122,9 +129,9 @@ function App() {
const [apiKey, setApiKey] = useState(localStorage.getItem('gemini_key') || ''); const [apiKey, setApiKey] = useState(localStorage.getItem('gemini_key') || '');
// Social API State - Load encrypted or plain // Social API State - Load encrypted or plain
const [uploadPostKey, setUploadPostKey] = useState(() => { const [uploadPostKey, setUploadPostKey] = useState(() => {
const stored = localStorage.getItem('uploadPostKey_v2'); // Changed key to force re-login or fresh start if needed const stored = localStorage.getItem('uploadPostKey_v3');
if (stored) return decrypt(stored); if (stored) return decrypt(stored);
return ''; return '';
}); });
const [uploadUserId, setUploadUserId] = useState(() => localStorage.getItem('uploadUserId') || ''); const [uploadUserId, setUploadUserId] = useState(() => localStorage.getItem('uploadUserId') || '');
@ -138,15 +145,17 @@ function App() {
const [activeTab, setActiveTab] = useState('dashboard'); // dashboard, settings const [activeTab, setActiveTab] = useState('dashboard'); // dashboard, settings
useEffect(() => { useEffect(() => {
// Encrypt Gemini Key too for consistency if desired, but user asked specifically about Social integration not saving well.
// For now keeping gemini plain for compatibility unless requested.
if (apiKey) localStorage.setItem('gemini_key', apiKey); if (apiKey) localStorage.setItem('gemini_key', apiKey);
}, [apiKey]); }, [apiKey]);
useEffect(() => { useEffect(() => {
if (uploadPostKey) { if (uploadPostKey) {
localStorage.setItem('uploadPostKey_v2', encrypt(uploadPostKey)); localStorage.setItem('uploadPostKey_v3', encrypt(uploadPostKey));
} }
if (uploadUserId) { if (uploadUserId) {
localStorage.setItem('uploadUserId', uploadUserId); localStorage.setItem('uploadUserId', uploadUserId);
} }
}, [uploadPostKey, uploadUserId]); }, [uploadPostKey, uploadUserId]);
@ -260,8 +269,8 @@ function App() {
const Sidebar = () => ( const Sidebar = () => (
<div className="w-20 lg:w-64 bg-surface border-r border-white/5 flex flex-col h-full shrink-0 transition-all duration-300"> <div className="w-20 lg:w-64 bg-surface border-r border-white/5 flex flex-col h-full shrink-0 transition-all duration-300">
<div className="p-6 flex items-center gap-3"> <div className="p-6 flex items-center gap-3">
<div className="w-8 h-8 bg-primary rounded-lg flex items-center justify-center shrink-0"> <div className="w-8 h-8 bg-white/5 rounded-lg flex items-center justify-center shrink-0 overflow-hidden border border-white/5">
<Sparkles size={18} className="text-white" /> <img src="/logo-openshorts.png" alt="Logo" className="w-full h-full object-cover" />
</div> </div>
<span className="font-bold text-lg text-white hidden lg:block tracking-tight">OpenShorts</span> <span className="font-bold text-lg text-white hidden lg:block tracking-tight">OpenShorts</span>
</div> </div>
@ -292,11 +301,11 @@ function App() {
className="flex items-center gap-2 p-3 bg-white/5 hover:bg-white/10 rounded-xl transition-colors group" className="flex items-center gap-2 p-3 bg-white/5 hover:bg-white/10 rounded-xl transition-colors group"
> >
<div className="w-8 h-8 rounded-full bg-white text-black flex items-center justify-center shrink-0"> <div className="w-8 h-8 rounded-full bg-white text-black flex items-center justify-center shrink-0">
<svg height="20" viewBox="0 0 16 16" version="1.1" width="20" aria-hidden="true"><path fillRule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg> <svg height="20" viewBox="0 0 16 16" version="1.1" width="20" aria-hidden="true"><path fillRule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
</div> </div>
<div className="hidden lg:block overflow-hidden"> <div className="hidden lg:block overflow-hidden">
<p className="text-sm font-bold text-white leading-none mb-0.5">Open Source</p> <p className="text-sm font-bold text-white leading-none mb-0.5">Open Source</p>
<p className="text-[10px] text-zinc-400 group-hover:text-zinc-300 transition-colors truncate">Free & Community Driven</p> <p className="text-[10px] text-zinc-400 group-hover:text-zinc-300 transition-colors truncate">Free & Community Driven</p>
</div> </div>
</a> </a>
</div> </div>
@ -310,38 +319,38 @@ function App() {
<main className="flex-1 flex flex-col h-full overflow-hidden relative"> <main className="flex-1 flex flex-col h-full overflow-hidden relative">
{/* Background Gradients */} {/* Background Gradients */}
<div className="absolute inset-0 overflow-hidden -z-10 pointer-events-none"> <div className="absolute inset-0 overflow-hidden -z-10 pointer-events-none">
<div className="absolute -top-[10%] -right-[10%] w-[50%] h-[50%] bg-primary/5 rounded-full blur-[120px]" /> <div className="absolute -top-[10%] -right-[10%] w-[50%] h-[50%] bg-primary/5 rounded-full blur-[120px]" />
</div> </div>
{/* Top Header */} {/* Top Header */}
<header className="h-16 border-b border-white/5 bg-background/50 backdrop-blur-md flex items-center justify-between px-6 shrink-0 z-10"> <header className="h-16 border-b border-white/5 bg-background/50 backdrop-blur-md flex items-center justify-between px-6 shrink-0 z-10">
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
{status !== 'idle' && ( {status !== 'idle' && (
<button <button
onClick={handleReset} onClick={handleReset}
className="flex items-center gap-2 text-sm text-zinc-400 hover:text-white transition-colors" className="flex items-center gap-2 text-sm text-zinc-400 hover:text-white transition-colors"
> >
<PlusCircle size={16} /> <PlusCircle size={16} />
<span className="hidden sm:inline">New Project</span> <span className="hidden sm:inline">New Project</span>
</button> </button>
)} )}
</div> </div>
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
{userProfiles.length > 0 && ( {userProfiles.length > 0 && (
<UserProfileSelector <UserProfileSelector
profiles={userProfiles} profiles={userProfiles}
selectedUserId={uploadUserId} selectedUserId={uploadUserId}
onSelect={setUploadUserId} onSelect={setUploadUserId}
/> />
)} )}
{!apiKey && ( {!apiKey && (
<span className="text-xs text-amber-500 bg-amber-500/10 px-3 py-1 rounded-full border border-amber-500/20"> <span className="text-xs text-amber-500 bg-amber-500/10 px-3 py-1 rounded-full border border-amber-500/20">
API Key Missing API Key Missing
</span> </span>
)} )}
</div> </div>
</header> </header>
{/* Main Workspace */} {/* Main Workspace */}
@ -349,57 +358,78 @@ function App() {
{/* View: Settings */} {/* View: Settings */}
{activeTab === 'settings' && ( {activeTab === 'settings' && (
<div className="h-full overflow-y-auto p-8 max-w-2xl mx-auto animate-[fadeIn_0.3s_ease-out]"> <div className="h-full overflow-y-auto p-8 max-w-2xl mx-auto animate-[fadeIn_0.3s_ease-out]">
<h1 className="text-2xl font-bold mb-8">Settings</h1> <div className="flex items-center justify-between mb-8">
<KeyInput onKeySet={setApiKey} savedKey={apiKey} /> <h1 className="text-2xl font-bold">Settings</h1>
<div className="px-3 py-1 bg-green-500/10 border border-green-500/20 rounded-full text-[10px] text-green-400 font-medium flex items-center gap-2">
<Shield size={12} /> Privacy: keys only live in your browser (sent to backend just to process)
</div>
</div>
<KeyInput onKeySet={setApiKey} savedKey={apiKey} />
<div className="glass-panel p-6 mt-8"> <div className="glass-panel p-6 mt-8">
<h2 className="text-lg font-semibold mb-4">Social Integration</h2> <h2 className="text-lg font-semibold mb-4">Social Integration</h2>
<div className="space-y-4"> <div className="space-y-4">
<label className="block text-sm text-zinc-400">Upload-Post API Key</label> <label className="block text-sm text-zinc-400">Upload-Post API Key</label>
<div className="flex gap-2"> <div className="flex gap-2">
<input <input
type="password" type="password"
value={uploadPostKey} value={uploadPostKey}
onChange={(e) => setUploadPostKey(e.target.value)} onChange={(e) => setUploadPostKey(e.target.value)}
className="input-field" className="input-field"
placeholder="ey..." placeholder="ey..."
/> />
<button onClick={fetchUserProfiles} className="btn-primary py-2 px-4 text-sm"> <button onClick={fetchUserProfiles} className="btn-primary py-2 px-4 text-sm">
Connect Connect
</button> </button>
</div> </div>
<p className="text-xs text-zinc-500"> <p className="text-xs text-zinc-500 leading-relaxed">
Connect your Upload-Post account to enable one-click publishing. Connect your Upload-Post account to enable one-click publishing.
<br/> <div className="mt-3 grid grid-cols-1 sm:grid-cols-3 gap-2">
<span className="text-zinc-600 italic">Key stored encrypted locally.</span> <a href="https://app.upload-post.com/login" target="_blank" rel="noopener noreferrer" className="p-2 border border-white/5 rounded-lg hover:bg-white/5 transition-colors flex flex-col gap-1">
</p> <span className="text-zinc-400 font-medium">1. Login</span>
<span className="text-[10px] text-zinc-600">Register account</span>
</a>
<a href="https://app.upload-post.com/manage-users" target="_blank" rel="noopener noreferrer" className="p-2 border border-white/5 rounded-lg hover:bg-white/5 transition-colors flex flex-col gap-1">
<span className="text-zinc-400 font-medium">2. Profiles</span>
<span className="text-[10px] text-zinc-600">Create & Connect</span>
</a>
<a href="https://app.upload-post.com/api-keys" target="_blank" rel="noopener noreferrer" className="p-2 border border-white/5 rounded-lg hover:bg-white/5 transition-colors flex flex-col gap-1">
<span className="text-zinc-400 font-medium">3. API Key</span>
<span className="text-[10px] text-zinc-600">Generate key</span>
</a>
</div> </div>
</div> <br />
</div> <span className="text-zinc-600 italic">
Keys are only stored in your browser. They are sent to the backend only to process your request, never stored server-side.
</span>
</p>
</div>
</div>
</div>
)} )}
{/* View: Dashboard (Idle) */} {/* View: Dashboard (Idle) */}
{activeTab === 'dashboard' && status === 'idle' && ( {activeTab === 'dashboard' && status === 'idle' && (
<div className="h-full flex flex-col items-center justify-center p-6 animate-[fadeIn_0.3s_ease-out]"> <div className="h-full flex flex-col items-center justify-center p-6 animate-[fadeIn_0.3s_ease-out]">
<div className="max-w-xl w-full text-center space-y-8"> <div className="max-w-xl w-full text-center space-y-8">
<div className="space-y-4"> <div className="space-y-4">
<h1 className="text-4xl md:text-5xl font-black bg-gradient-to-b from-white to-white/60 bg-clip-text text-transparent"> <h1 className="text-4xl md:text-5xl font-black bg-gradient-to-b from-white to-white/60 bg-clip-text text-transparent">
Create Viral Shorts Create Viral Shorts
</h1> </h1>
<p className="text-zinc-400 text-lg"> <p className="text-zinc-400 text-lg">
Drop your long-form video URL or file below to instantly generate viral clips with AI. Drop your long-form video URL or file below to instantly generate viral clips with AI.
</p> </p>
</div> </div>
<MediaInput onProcess={handleProcess} isProcessing={status === 'processing'} /> <MediaInput onProcess={handleProcess} isProcessing={status === 'processing'} />
<div className="flex items-center justify-center gap-8 text-zinc-500 text-sm"> <div className="flex items-center justify-center gap-8 text-zinc-500 text-sm">
<span className="flex items-center gap-2"><Youtube size={16} /> YouTube</span> <span className="flex items-center gap-2"><Youtube size={16} /> YouTube</span>
<span className="flex items-center gap-2"><Instagram size={16} /> Instagram</span> <span className="flex items-center gap-2"><Instagram size={16} /> Instagram</span>
<span className="flex items-center gap-2"><TikTokIcon size={16} /> TikTok</span> <span className="flex items-center gap-2"><TikTokIcon size={16} /> TikTok</span>
</div> </div>
</div> </div>
</div> </div>
)} )}
@ -409,88 +439,87 @@ function App() {
{/* Left Panel: Preview & Status */} {/* Left Panel: Preview & Status */}
<div className={`${status === 'complete' ? 'w-full md:w-[30%] lg:w-[25%]' : 'w-full md:w-[55%] lg:w-[60%]'} h-full flex flex-col border-r border-white/5 bg-black/20 p-6 overflow-y-auto custom-scrollbar transition-all duration-700 ease-in-out`}> <div className={`${status === 'complete' ? 'w-full md:w-[30%] lg:w-[25%]' : 'w-full md:w-[55%] lg:w-[60%]'} h-full flex flex-col border-r border-white/5 bg-black/20 p-6 overflow-y-auto custom-scrollbar transition-all duration-700 ease-in-out`}>
<div className="mb-6 flex items-center justify-between"> <div className="mb-6 flex items-center justify-between">
<h2 className="text-lg font-semibold flex items-center gap-2"> <h2 className="text-lg font-semibold flex items-center gap-2">
<Activity className={`text-primary ${status === 'processing' ? 'animate-pulse' : ''}`} size={20} /> <Activity className={`text-primary ${status === 'processing' ? 'animate-pulse' : ''}`} size={20} />
Live Analysis Live Analysis
</h2> </h2>
<span className={`text-xs px-2 py-1 rounded-full border ${ <span className={`text-xs px-2 py-1 rounded-full border ${status === 'processing' ? 'bg-primary/10 border-primary/20 text-primary' :
status === 'processing' ? 'bg-primary/10 border-primary/20 text-primary' : status === 'complete' ? 'bg-green-500/10 border-green-500/20 text-green-400' :
status === 'complete' ? 'bg-green-500/10 border-green-500/20 text-green-400' :
'bg-red-500/10 border-red-500/20 text-red-400' 'bg-red-500/10 border-red-500/20 text-red-400'
}`}> }`}>
{status.toUpperCase()} {status.toUpperCase()}
</span> </span>
</div>
{/* Video Preview */}
{processingMedia && <ProcessingAnimation media={processingMedia} isComplete={status === 'complete'} />}
{/* Logs Terminal */}
<div className={`bg-[#0c0c0e] rounded-xl border border-white/10 overflow-hidden flex flex-col transition-all duration-500 ${status === 'complete' ? 'h-32 min-h-0 opacity-50 hover:opacity-100' : 'flex-1 min-h-[200px]'}`}>
<div className="px-4 py-2 border-b border-white/5 flex items-center justify-between bg-white/5 shrink-0">
<span className="text-xs font-mono text-zinc-400 flex items-center gap-2">
<Terminal size={12} /> System Logs
</span>
<button onClick={() => setLogsVisible(!logsVisible)} className="text-zinc-500 hover:text-white transition-colors">
{logsVisible ? <ChevronDown size={14} /> : <ChevronDown size={14} className="rotate-180" />}
</button>
</div> </div>
{logsVisible && (
{/* Video Preview */} <div className="flex-1 p-4 overflow-y-auto font-mono text-xs space-y-1.5 custom-scrollbar text-zinc-400">
{processingMedia && <ProcessingAnimation media={processingMedia} isComplete={status === 'complete'} />} {logs.map((log, i) => (
<div key={i} className={`flex gap-2 ${log.toLowerCase().includes('error') ? 'text-red-400' : 'text-zinc-400'}`}>
{/* Logs Terminal */} <span className="text-zinc-700 shrink-0">{new Date().toLocaleTimeString()}</span>
<div className={`bg-[#0c0c0e] rounded-xl border border-white/10 overflow-hidden flex flex-col transition-all duration-500 ${status === 'complete' ? 'h-32 min-h-0 opacity-50 hover:opacity-100' : 'flex-1 min-h-[200px]'}`}> <span>{log}</span>
<div className="px-4 py-2 border-b border-white/5 flex items-center justify-between bg-white/5 shrink-0">
<span className="text-xs font-mono text-zinc-400 flex items-center gap-2">
<Terminal size={12} /> System Logs
</span>
<button onClick={() => setLogsVisible(!logsVisible)} className="text-zinc-500 hover:text-white transition-colors">
{logsVisible ? <ChevronDown size={14} /> : <ChevronDown size={14} className="rotate-180" />}
</button>
</div>
{logsVisible && (
<div className="flex-1 p-4 overflow-y-auto font-mono text-xs space-y-1.5 custom-scrollbar text-zinc-400">
{logs.map((log, i) => (
<div key={i} className={`flex gap-2 ${log.toLowerCase().includes('error') ? 'text-red-400' : 'text-zinc-400'}`}>
<span className="text-zinc-700 shrink-0">{new Date().toLocaleTimeString()}</span>
<span>{log}</span>
</div>
))}
{status === 'processing' && (
<div className="animate-pulse text-primary/70">_</div>
)}
</div> </div>
)} ))}
</div> {status === 'processing' && (
<div className="animate-pulse text-primary/70">_</div>
)}
</div>
)}
</div>
</div> </div>
{/* Right Panel: Results Grid */} {/* Right Panel: Results Grid */}
<div className={`${status === 'complete' ? 'w-full md:w-[70%] lg:w-[75%]' : 'w-full md:w-[45%] lg:w-[40%]'} h-full flex flex-col bg-background p-6 transition-all duration-700 ease-in-out`}> <div className={`${status === 'complete' ? 'w-full md:w-[70%] lg:w-[75%]' : 'w-full md:w-[45%] lg:w-[40%]'} h-full flex flex-col bg-background p-6 transition-all duration-700 ease-in-out`}>
<h2 className="text-lg font-semibold mb-6 flex items-center gap-2 shrink-0"> <h2 className="text-lg font-semibold mb-6 flex items-center gap-2 shrink-0">
<Sparkles className="text-yellow-400" size={20} /> <Sparkles className="text-yellow-400" size={20} />
Generated Shorts Generated Shorts
{results?.clips?.length > 0 && ( {results?.clips?.length > 0 && (
<span className="text-xs bg-white/10 text-white px-2 py-0.5 rounded-full ml-auto"> <span className="text-xs bg-white/10 text-white px-2 py-0.5 rounded-full ml-auto">
{results.clips.length} Clips {results.clips.length} Clips
</span> </span>
)} )}
</h2> </h2>
<div className="flex-1 overflow-y-auto custom-scrollbar p-1"> <div className="flex-1 overflow-y-auto custom-scrollbar p-1">
{results && results.clips && results.clips.length > 0 ? ( {results && results.clips && results.clips.length > 0 ? (
<div className="grid grid-cols-1 xl:grid-cols-2 gap-4 pb-10"> <div className="grid grid-cols-1 xl:grid-cols-2 gap-4 pb-10">
{results.clips.map((clip, i) => ( {results.clips.map((clip, i) => (
<ResultCard <ResultCard
key={i} key={i}
clip={clip} clip={clip}
index={i} index={i}
jobId={jobId} jobId={jobId}
uploadPostKey={uploadPostKey} uploadPostKey={uploadPostKey}
uploadUserId={uploadUserId} uploadUserId={uploadUserId}
/> />
))} ))}
</div> </div>
) : ( ) : (
status === 'processing' ? ( status === 'processing' ? (
<div className="h-full flex flex-col items-center justify-center text-zinc-500 space-y-4 opacity-50"> <div className="h-full flex flex-col items-center justify-center text-zinc-500 space-y-4 opacity-50">
<div className="w-12 h-12 rounded-full border-2 border-zinc-800 border-t-primary animate-spin" /> <div className="w-12 h-12 rounded-full border-2 border-zinc-800 border-t-primary animate-spin" />
<p className="text-sm">Waiting for clips...</p> <p className="text-sm">Waiting for clips...</p>
</div> </div>
) : status === 'error' ? ( ) : status === 'error' ? (
<div className="h-full flex flex-col items-center justify-center text-red-400 space-y-2"> <div className="h-full flex flex-col items-center justify-center text-red-400 space-y-2">
<p>Generation failed.</p> <p>Generation failed.</p>
</div> </div>
) : null ) : null
)} )}
</div> </div>
</div> </div>
</div> </div>

View file

@ -49,8 +49,8 @@ export default function KeyInput({ onKeySet, savedKey }) {
onClick={handleSave} onClick={handleSave}
disabled={!key || isSaved} disabled={!key || isSaved}
className={`px-6 rounded-xl font-medium transition-all flex items-center gap-2 ${isSaved className={`px-6 rounded-xl font-medium transition-all flex items-center gap-2 ${isSaved
? 'bg-green-500/20 text-green-400 cursor-default' ? 'bg-green-500/20 text-green-400 cursor-default'
: 'bg-primary hover:bg-blue-600 text-white shadow-lg shadow-primary/20' : 'bg-primary hover:bg-blue-600 text-white shadow-lg shadow-primary/20'
}`} }`}
> >
{isSaved ? <><Check size={18} /> Ready</> : 'Set Key'} {isSaved ? <><Check size={18} /> Ready</> : 'Set Key'}
@ -58,6 +58,15 @@ export default function KeyInput({ onKeySet, savedKey }) {
</div> </div>
<p className="mt-3 text-xs text-zinc-500"> <p className="mt-3 text-xs text-zinc-500">
Your key is stored locally in your browser for convenience. Your key is stored locally in your browser for convenience.
<br />
<a
href="https://aistudio.google.com/app/apikey"
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline mt-1 inline-block"
>
Get your free Gemini API Key here →
</a>
</p> </p>
</div> </div>
); );