fix(ui): live karaoke preview (dim/uppercase/effects) + no local Gemini key required for managed users
- SubtitleModal: karaoke styles burn server-side, so the Remotion preview never reflected dim/uppercase/effect controls. Show a CSS mock that mirrors the burned ASS look (opaque scaled dim color, uppercase, glow/ pop/box on the active word) using the clip's own first words. - ResultCard: auto-edit demanded a local Gemini key even for managed (paid) users whose key resolves server-side; only BYOK needs one now.
This commit is contained in:
parent
459c062851
commit
eb7504f00a
2 changed files with 46 additions and 3 deletions
|
|
@ -105,16 +105,19 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
||||||
try {
|
try {
|
||||||
const apiKey = geminiApiKey || localStorage.getItem('gemini_key');
|
const apiKey = geminiApiKey || localStorage.getItem('gemini_key');
|
||||||
|
|
||||||
if (!apiKey) {
|
// Managed (paid) users get the Gemini key resolved server-side;
|
||||||
|
// only BYOK/self-host needs a local key.
|
||||||
|
if (!apiKey && !isManaged) {
|
||||||
throw new Error("Gemini API Key is missing. Please set it in Settings.");
|
throw new Error("Gemini API Key is missing. Please set it in Settings.");
|
||||||
}
|
}
|
||||||
|
const geminiHeaders = apiKey ? { 'X-Gemini-Key': apiKey } : {};
|
||||||
|
|
||||||
// Try Remotion effects endpoint first
|
// Try Remotion effects endpoint first
|
||||||
const effectsRes = await apiFetch('/api/effects/generate', {
|
const effectsRes = await apiFetch('/api/effects/generate', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Gemini-Key': apiKey
|
...geminiHeaders
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
job_id: jobId,
|
job_id: jobId,
|
||||||
|
|
@ -146,7 +149,7 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Gemini-Key': apiKey
|
...geminiHeaders
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
job_id: jobId,
|
job_id: jobId,
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,16 @@ const CAPTION_PRESETS = [
|
||||||
{ id: 'classic', label: 'Classic', style: 'classic', effect: 'none', highlightColor: '#FFD700', baseOpacity: 1.0, uppercase: false, fontName: 'Verdana', borderWidth: 2 },
|
{ id: 'classic', label: 'Classic', style: 'classic', effect: 'none', highlightColor: '#FFD700', baseOpacity: 1.0, uppercase: false, fontName: 'Verdana', borderWidth: 2 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Mirrors the backend's ASS dimming: a fully-opaque scaled color (not CSS
|
||||||
|
// opacity), so the preview matches what gets burned into the video.
|
||||||
|
const dimColor = (hex, k) => {
|
||||||
|
const m = /^#?([0-9a-f]{6})$/i.exec(hex || '');
|
||||||
|
if (!m) return hex;
|
||||||
|
const scale = 0.35 + 0.65 * k;
|
||||||
|
const [r, g, b] = [0, 2, 4].map(i => Math.round(parseInt(m[1].slice(i, i + 2), 16) * scale));
|
||||||
|
return `rgb(${r}, ${g}, ${b})`;
|
||||||
|
};
|
||||||
|
|
||||||
const swatchClass = (selected) =>
|
const swatchClass = (selected) =>
|
||||||
`w-6 h-6 rounded-full transition-all ${selected
|
`w-6 h-6 rounded-full transition-all ${selected
|
||||||
? 'ring-2 ring-[color:var(--color-accent)] ring-offset-2 ring-offset-[color:var(--color-paper-2)]'
|
? 'ring-2 ring-[color:var(--color-accent)] ring-offset-2 ring-offset-[color:var(--color-paper-2)]'
|
||||||
|
|
@ -210,6 +220,36 @@ export default function SubtitleModal({ isOpen, onClose, onGenerate, isProcessin
|
||||||
<Loader2 size={16} className="animate-spin" />
|
<Loader2 size={16} className="animate-spin" />
|
||||||
<span className="text-sm lowercase">Loading preview...</span>
|
<span className="text-sm lowercase">Loading preview...</span>
|
||||||
</div>
|
</div>
|
||||||
|
) : style === 'karaoke' ? (
|
||||||
|
/* Karaoke burns server-side; show a CSS mock that mirrors
|
||||||
|
the exact burned look (dim, uppercase, effects). */
|
||||||
|
<>
|
||||||
|
<video src={videoUrl} className="w-full h-full object-contain opacity-50" muted playsInline />
|
||||||
|
<div className={`absolute w-full px-8 text-center pointer-events-none flex flex-col items-center justify-center
|
||||||
|
${position === 'top' ? 'top-20' : position === 'middle' ? 'top-0 bottom-0' : 'bottom-20'}
|
||||||
|
`}>
|
||||||
|
<span style={{ ...fallbackPreviewStyle, color: undefined }}>
|
||||||
|
{(captions.length >= 4
|
||||||
|
? captions.slice(0, 4).map(c => c.text)
|
||||||
|
: ['this', 'word', 'is', 'spoken']
|
||||||
|
).map((w, i) => {
|
||||||
|
const word = uppercase ? w.toUpperCase() : w;
|
||||||
|
const active = i === 1;
|
||||||
|
if (!active) {
|
||||||
|
return <span key={i} style={{ color: dimColor(fontColor, baseOpacity) }}>{word} </span>;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<span key={i} style={{
|
||||||
|
color: effect === 'box' ? '#FFFFFF' : highlightColor,
|
||||||
|
...(effect === 'glow' ? { textShadow: `0 0 6px ${highlightColor}, 0 0 14px ${highlightColor}` } : {}),
|
||||||
|
...(effect === 'pop' ? { display: 'inline-block', transform: 'scale(1.18)', margin: '0 3px' } : {}),
|
||||||
|
...(effect === 'box' ? { backgroundColor: highlightColor, borderRadius: '4px', padding: '0 5px' } : {}),
|
||||||
|
}}>{word} </span>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
) : useRemotionPreview ? (
|
) : useRemotionPreview ? (
|
||||||
<RemotionPreview
|
<RemotionPreview
|
||||||
videoUrl={videoUrl}
|
videoUrl={videoUrl}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue