diff --git a/app/api/meta/video/route.ts b/app/api/meta/video/route.ts
index d6db68a..9b8294e 100644
--- a/app/api/meta/video/route.ts
+++ b/app/api/meta/video/route.ts
@@ -4,12 +4,14 @@ import { MetaCrawlClient } from '@/lib/providers/meta-crawl-client';
/**
* POST /api/meta/video
*
- * Generate a video from a text prompt using Meta AI.
+ * Generate a video from a text prompt (and optionally an image) using Meta AI.
+ * - Text-to-Video: Just provide prompt and cookies
+ * - Image-to-Video: Also provide imageBase64
* Video generation takes 30-60+ seconds, so this endpoint may take a while.
*/
export async function POST(req: NextRequest) {
try {
- const { prompt, cookies: clientCookies } = await req.json();
+ const { prompt, cookies: clientCookies, imageBase64 } = await req.json();
if (!prompt) {
return NextResponse.json({ error: "Prompt is required" }, { status: 400 });
@@ -25,7 +27,8 @@ export async function POST(req: NextRequest) {
);
}
- console.log(`[Meta Video API] Starting video generation for prompt: "${prompt.substring(0, 50)}..."`);
+ const mode = imageBase64 ? 'image-to-video' : 'text-to-video';
+ console.log(`[Meta Video API] Starting ${mode} for prompt: "${prompt.substring(0, 50)}..."`);
const client = new MetaCrawlClient();
@@ -39,7 +42,7 @@ export async function POST(req: NextRequest) {
}
// Generate video - this can take 30-60+ seconds
- const result = await client.generateVideo(prompt, cookieString);
+ const result = await client.generateVideo(prompt, cookieString, imageBase64);
if (!result.success || result.videos.length === 0) {
throw new Error(result.error || "No videos generated");
diff --git a/components/PromptHero.tsx b/components/PromptHero.tsx
index 03214b7..bcad359 100644
--- a/components/PromptHero.tsx
+++ b/components/PromptHero.tsx
@@ -206,6 +206,8 @@ export function PromptHero() {
};
// Handle video generation (Meta AI only)
+ // If a subject reference is set, it will use image-to-video
+ // Otherwise, it will use text-to-video
const handleGenerateVideo = async () => {
let finalPrompt = prompt.trim();
if (!finalPrompt || isGeneratingVideo || settings.provider !== 'meta') return;
@@ -214,14 +216,20 @@ export function PromptHero() {
setIsGenerating(true);
try {
- console.log('[PromptHero] Starting Meta AI video generation...');
+ // Check if we have a subject reference for image-to-video
+ const subjectRefs = references.subject || [];
+ const imageBase64 = subjectRefs.length > 0 ? subjectRefs[0].thumbnail : undefined;
+ const mode = imageBase64 ? 'image-to-video' : 'text-to-video';
+
+ console.log(`[PromptHero] Starting Meta AI ${mode}...`);
const res = await fetch('/api/meta/video', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
prompt: finalPrompt,
- cookies: settings.metaCookies
+ cookies: settings.metaCookies,
+ imageBase64: imageBase64
})
});
@@ -243,12 +251,13 @@ export function PromptHero() {
id: crypto.randomUUID(),
url: video.url,
prompt: video.prompt || finalPrompt,
+ thumbnail: imageBase64, // Store the source image as thumbnail
createdAt: Date.now()
});
}
// Show success notification
setErrorNotification({
- message: `🎬 Success! Generated ${data.videos.length} video(s). Check the Videos tab.`,
+ message: `🎬 Success! Generated ${data.videos.length} video(s) via ${mode}. Check the gallery.`,
type: 'warning' // Using warning for visibility (amber color)
});
setTimeout(() => setErrorNotification(null), 5000);
@@ -557,14 +566,20 @@ export function PromptHero() {
{/* Controls Area */}
- {/* Left Controls: References (Hidden for Meta AI as it doesn't support them yet) */}
-
+ {/* Left Controls: References */}
+ {/* For Meta AI: Only subject is enabled (for image-to-video), scene/style are disabled */}
+
{(['subject', 'scene', 'style'] as ReferenceCategory[]).map((cat) => {
const refs = references[cat] || [];
const hasRefs = refs.length > 0;
const isUploading = uploadingRefs[cat];
+ // For Meta AI: only enable subject (for image-to-video), disable scene/style
+ const isDisabledForMeta = settings.provider === 'meta' && cat !== 'subject';
return (
-
+