- Click to view
+
+ {clip.thumbnail_storage_path ? (
+
+ ) : (
+
+ No thumbnail
+
+ )}
@@ -139,7 +161,7 @@ export function UserClips({ clips, onClipDeleted, onClipUpdated }: UserClipsProp
Are you sure?
- This action cannot be undone. This will permanently delete your clip and remove its data from our servers.
+ This action cannot be undone. This will permanently delete your clip and its thumbnail from our servers.
diff --git a/src/components/video-editor.tsx b/src/components/video-editor.tsx
index 31d6bae..ece3db8 100644
--- a/src/components/video-editor.tsx
+++ b/src/components/video-editor.tsx
@@ -118,16 +118,26 @@ export function VideoEditor() {
const data = await ffmpeg.readFile('output.mp4');
const trimmedBlob = new Blob([(data as any).buffer], { type: 'video/mp4' });
+
+ // Generate thumbnail
+ await ffmpeg.exec(['-i', 'output.mp4', '-ss', '00:00:00.001', '-vframes', '1', 'thumbnail.jpg']);
+ const thumbnailData = await ffmpeg.readFile('thumbnail.jpg');
+ const thumbnailBlob = new Blob([(thumbnailData as any).buffer], { type: 'image/jpeg' });
const shortId = Math.random().toString(36).substring(2, 8);
const storagePath = `${user.id}/${shortId}-${videoFile.name}`;
+ const thumbnailStoragePath = `${user.id}/${shortId}-thumbnail.jpg`;
const { error: uploadError } = await supabase.storage.from('clips').upload(storagePath, trimmedBlob);
if (uploadError) throw new Error(`Storage Error: ${uploadError.message}`);
+ const { error: thumbnailUploadError } = await supabase.storage.from('clips').upload(thumbnailStoragePath, thumbnailBlob);
+ if (thumbnailUploadError) throw new Error(`Thumbnail Upload Error: ${thumbnailUploadError.message}`);
+
const { error: dbError } = await supabase.from('clips').insert({
user_id: user.id,
storage_path: storagePath,
+ thumbnail_storage_path: thumbnailStoragePath,
short_id: shortId,
original_file_name: videoFile.name,
title: videoTitle,