Spaces:
Paused

undefined / index.html
theflowercat's picture
认真看下官网有这些参数么。按官方有的参数来写,不要自己瞎编。比如时长就是固定可选值,看下官方的参数,有哪些,按他的来。
7c79f12 verified
Raw History Blame Contribute Delete
18.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SoraVision: AI Video Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.waves.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');
:root {
--primary: #6366f1;
--secondary: #8b5cf6;
}
body {
font-family: 'Inter', sans-serif;
}
.title-font {
font-family: 'Space Grotesk', sans-serif;
}
.gradient-text {
background: linear-gradient(90deg, var(--primary), var(--secondary));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.custom-scrollbar::-webkit-scrollbar {
width: 6px;
height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.3);
border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.5);
}
.video-container {
aspect-ratio: 16 / 9;
background: linear-gradient(45deg, #1e293b, #0f172a);
}
.param-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: white;
cursor: pointer;
box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}
</style>
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen">
<div id="vanta-bg" class="fixed inset-0 -z-10"></div>
<div class="container mx-auto px-4 py-12">
<!-- Header -->
<header class="mb-16 text-center">
<h1 class="title-font text-5xl md:text-6xl font-bold mb-4">
<span class="gradient-text">SoraVision</span>
</h1>
<p class="text-xl text-gray-300 max-w-2xl mx-auto">
Transform your creative visions into stunning AI-generated videos with OpenAI's Sora API
</p>
</header>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Video Preview Section -->
<div class="lg:col-span-2 space-y-6">
<div class="bg-gray-800/50 backdrop-blur-lg rounded-2xl border border-gray-700/50 overflow-hidden shadow-2xl">
<div class="video-container w-full relative group">
<div id="video-placeholder" class="w-full h-full flex items-center justify-center">
<div class="text-center p-8">
<i data-feather="video" class="w-16 h-16 mx-auto text-gray-500 mb-4"></i>
<h3 class="text-2xl font-semibold text-gray-400 mb-2">Your AI Video Preview</h3>
<p class="text-gray-500">Generate a video to see it appear here</p>
</div>
</div>
<video id="generated-video" class="w-full h-full hidden" controls></video>
</div>
<div class="p-6 border-t border-gray-700/50">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold">Video Output</h3>
<button id="download-btn" class="hidden px-4 py-2 bg-indigo-600 hover:bg-indigo-700 rounded-lg flex items-center gap-2 transition-colors">
<i data-feather="download"></i>
<span>Download</span>
</button>
</div>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-300 mb-1">Status</label>
<div id="status-indicator" class="px-4 py-2 bg-gray-700 rounded-lg flex items-center gap-2">
<div class="w-3 h-3 rounded-full bg-gray-500" id="status-dot"></div>
<span id="status-text">Ready to generate</span>
</div>
</div>
<div id="progress-container" class="hidden">
<div class="flex justify-between text-sm text-gray-300 mb-1">
<span>Generation Progress</span>
<span id="progress-percent">0%</span>
</div>
<div class="w-full bg-gray-700 rounded-full h-2.5">
<div id="progress-bar" class="bg-indigo-500 h-2.5 rounded-full" style="width: 0%"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Parameters Section -->
<div class="space-y-6">
<div class="bg-gray-800/50 backdrop-blur-lg rounded-2xl border border-gray-700/50 p-6 shadow-2xl">
<h2 class="text-2xl font-semibold mb-6 flex items-center gap-2">
<i data-feather="sliders" class="w-5 h-5"></i>
<span>Generation Parameters</span>
</h2>
<div class="space-y-6">
<div>
<label for="prompt" class="block text-sm font-medium text-gray-300 mb-1">Video Prompt</label>
<textarea id="prompt" rows="4" class="w-full px-4 py-3 bg-gray-700/50 border border-gray-600/50 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none transition-all" placeholder="Describe the video you want to generate..."></textarea>
</div>
<div>
<label for="duration" class="block text-sm font-medium text-gray-300 mb-1">Duration (seconds)</label>
<select id="duration" class="w-full px-4 py-3 bg-gray-700/50 border border-gray-600/50 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none transition-all">
<option value="10" selected>10 seconds</option>
<option value="20">20 seconds</option>
</select>
</div>
<div>
<label for="resolution" class="block text-sm font-medium text-gray-300 mb-1">Resolution</label>
<select id="resolution" class="w-full px-4 py-3 bg-gray-700/50 border border-gray-600/50 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none transition-all">
<option value="1920x1080" selected>1920x1080 (16:9)</option>
<option value="1280x720">1280x720 (16:9)</option>
<option value="1080x1920">1080x1920 (9:16)</option>
</select>
</div>
<div>
<label for="style" class="block text-sm font-medium text-gray-300 mb-1">Art Style</label>
<select id="style" class="w-full px-4 py-3 bg-gray-700/50 border border-gray-600/50 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none transition-all">
<option value="default" selected>Default Style</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-300 mb-1">Advanced Options</label>
<div class="space-y-3">
</div>
</div>
<button id="generate-btn" class="w-full py-3 px-6 bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-700 hover:to-purple-700 rounded-lg font-medium text-white flex items-center justify-center gap-2 transition-all shadow-lg hover:shadow-indigo-500/30">
<i data-feather="zap" class="w-5 h-5"></i>
<span>Generate Video</span>
</button>
</div>
</div>
<!-- History Section -->
<div class="bg-gray-800/50 backdrop-blur-lg rounded-2xl border border-gray-700/50 p-6 shadow-2xl">
<h2 class="text-2xl font-semibold mb-6 flex items-center gap-2">
<i data-feather="clock" class="w-5 h-5"></i>
<span>Generation History</span>
</h2>
<div id="history-list" class="space-y-3 max-h-60 overflow-y-auto custom-scrollbar pr-2">
<div class="text-center py-8 text-gray-500">
<i data-feather="archive" class="w-8 h-8 mx-auto mb-2"></i>
<p>Your generated videos will appear here</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Initialize Vanta.js background
VANTA.WAVES({
el: "#vanta-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x1e1b4b,
shininess: 50.00,
waveHeight: 15.00,
waveSpeed: 0.75,
zoom: 0.8
});
// Initialize Feather Icons
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// Update duration value display
const durationSlider = document.getElementById('duration');
const durationValue = document.getElementById('duration-value');
// Generate button click handler
const generateBtn = document.getElementById('generate-btn');
const videoPlaceholder = document.getElementById('video-placeholder');
const generatedVideo = document.getElementById('generated-video');
const downloadBtn = document.getElementById('download-btn');
const statusDot = document.getElementById('status-dot');
const statusText = document.getElementById('status-text');
const progressContainer = document.getElementById('progress-container');
const progressBar = document.getElementById('progress-bar');
const progressPercent = document.getElementById('progress-percent');
generateBtn.addEventListener('click', function() {
const prompt = document.getElementById('prompt').value.trim();
if (!prompt) {
alert('Please enter a video prompt');
return;
}
// Update UI for generation
generateBtn.disabled = true;
generateBtn.innerHTML = '<i data-feather="loader" class="w-5 h-5 animate-spin"></i><span>Generating...</span>';
feather.replace();
videoPlaceholder.classList.remove('hidden');
generatedVideo.classList.add('hidden');
generatedVideo.src = '';
downloadBtn.classList.add('hidden');
statusDot.className = 'w-3 h-3 rounded-full bg-yellow-500 animate-pulse';
statusText.textContent = 'Generating video...';
progressContainer.classList.remove('hidden');
// Simulate API call with progress updates
let progress = 0;
const interval = setInterval(() => {
progress += Math.random() * 10;
if (progress > 100) progress = 100;
progressBar.style.width = progress + '%';
progressPercent.textContent = Math.round(progress) + '%';
if (progress === 100) {
clearInterval(interval);
// Simulate successful generation
setTimeout(() => {
// In a real app, you would use the actual video URL from the API response
videoPlaceholder.classList.add('hidden');
generatedVideo.classList.remove('hidden');
generatedVideo.src = 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
generatedVideo.load();
downloadBtn.classList.remove('hidden');
generateBtn.disabled = false;
generateBtn.innerHTML = '<i data-feather="zap"></i><span>Generate Video</span>';
feather.replace();
statusDot.className = 'w-3 h-3 rounded-full bg-green-500';
statusText.textContent = 'Generation complete';
progressContainer.classList.add('hidden');
// Add to history
addToHistory(prompt);
}, 500);
}
}, 500);
});
// Download button click handler
downloadBtn.addEventListener('click', function() {
if (generatedVideo.src) {
const a = document.createElement('a');
a.href = generatedVideo.src;
a.download = 'soravision-video.mp4';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
});
// Add to history function
function addToHistory(prompt) {
const historyList = document.getElementById('history-list');
// If it's the placeholder, clear it
if (historyList.querySelector('.text-gray-500')) {
historyList.innerHTML = '';
}
const historyItem = document.createElement('div');
historyItem.className = 'bg-gray-700/50 hover:bg-gray-700/70 rounded-lg p-4 cursor-pointer transition-colors';
historyItem.innerHTML = `
<h3 class="font-medium text-gray-100 truncate">${prompt}</h3>
<div class="flex justify-between items-center mt-2">
<span class="text-xs text-gray-400">Just now</span>
<div class="flex gap-2">
<button class="text-indigo-400 hover:text-indigo-300">
<i data-feather="play" class="w-4 h-4"></i>
</button>
<button class="text-gray-400 hover:text-gray-300">
<i data-feather="trash-2" class="w-4 h-4"></i>
</button>
</div>
</div>
`;
historyList.insertBefore(historyItem, historyList.firstChild);
feather.replace();
}
// Play video from history
document.addEventListener('click', function(e) {
if (e.target.closest('[data-feather="play"]')) {
const historyItem = e.target.closest('.bg-gray-700/50');
const prompt = historyItem.querySelector('h3').textContent;
// In a real app, you would fetch the actual video from storage
document.getElementById('prompt').value = prompt;
// Simulate playing the video
videoPlaceholder.classList.add('hidden');
generatedVideo.classList.remove('hidden');
generatedVideo.src = 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
generatedVideo.load();
downloadBtn.classList.remove('hidden');
// Scroll to video section
document.querySelector('.video-container').scrollIntoView({
behavior: 'smooth'
});
}
});
});
</script>
</body>
</html>