@effectnode/media 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/movie-backend/agent/prompt/ltx.txt +20 -0
- package/dist/backend/movie-backend/agent/prompt/script.md +111 -1
- package/dist/backend/movie-backend/core.js +41 -0
- package/dist/backend/movie-backend/generation-queue.d.ts +1 -1
- package/dist/backend/movie-backend/generation-queue.js +75 -8
- package/dist/backend/movie-backend/render-media.d.ts +79 -2
- package/dist/backend/movie-backend/render-media.js +694 -418
- package/frontend/src/movie-app/components/EditorTabs/AdvancedVoiceCloneTab.tsx +366 -0
- package/frontend/src/movie-app/components/EditorTabs/AudioToVideoTab.tsx +406 -0
- package/frontend/src/movie-app/components/EditorTabs/FastImageEditTab.tsx +47 -0
- package/frontend/src/movie-app/components/EditorTabs/GenerateVideoTab.tsx +155 -1
- package/frontend/src/movie-app/components/EditorTabs/MovieStudioTab.tsx +33 -13
- package/frontend/src/movie-app/components/EditorTabs/SetupAiModelTab.tsx +26 -5
- package/frontend/src/movie-app/components/EditorTabs/UpscaleTab.tsx +343 -0
- package/frontend/src/movie-app/components/EditorTabs/VoiceCloneTab.tsx +365 -0
- package/frontend/src/movie-app/components/ProjectEditorPage.tsx +130 -125
- package/frontend/src/movie-app/stores/advancedVoiceCloneStore.ts +205 -0
- package/frontend/src/movie-app/stores/aiModelStore.ts +25 -2
- package/frontend/src/movie-app/stores/audioToVideoStore.ts +274 -0
- package/frontend/src/movie-app/stores/generationStore.ts +156 -255
- package/frontend/src/movie-app/stores/movieStudioStore.ts +10 -3
- package/frontend/src/movie-app/stores/queueStore.ts +47 -1
- package/frontend/src/movie-app/stores/upscaleStore.ts +118 -0
- package/frontend/src/movie-app/stores/voiceCloneStore.ts +227 -0
- package/package.json +1 -1
- package/frontend/src/movie-app/components/EditorTabs/BatchVoiceVideoTab.tsx +0 -913
- package/frontend/src/movie-app/components/EditorTabs/ExtendVideoTab.tsx +0 -305
- package/frontend/src/movie-app/components/EditorTabs/ExtractImageTab.tsx +0 -249
- package/frontend/src/movie-app/components/EditorTabs/SceneVisualTab.tsx +0 -267
- package/frontend/src/movie-app/lib/batchVoiceStorage.ts +0 -75
- package/frontend/src/movie-app/stores/batchVoiceStore.ts +0 -990
- package/frontend/src/movie-app/stores/sceneVisualStore.ts +0 -251
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useMemo, useState } from "react";
|
|
2
|
-
import { useGenerationStore } from "../../stores/generationStore";
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
projectId: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default function ExtendVideoTab({ projectId }: Props) {
|
|
9
|
-
const store = useGenerationStore();
|
|
10
|
-
const extendLogRef = useRef<HTMLPreElement | any>(null);
|
|
11
|
-
const [search, setSearch] = useState("");
|
|
12
|
-
|
|
13
|
-
const filteredVideos = useMemo(() => {
|
|
14
|
-
if (!search.trim()) return store.projectVideos;
|
|
15
|
-
const q = search.toLowerCase();
|
|
16
|
-
return store.projectVideos.filter((v) =>
|
|
17
|
-
v.filename.toLowerCase().includes(q),
|
|
18
|
-
);
|
|
19
|
-
}, [store.projectVideos, search]);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (extendLogRef.current) {
|
|
23
|
-
extendLogRef.current.scrollTop = 100000;
|
|
24
|
-
}
|
|
25
|
-
}, [store.extend.logs]);
|
|
26
|
-
|
|
27
|
-
const handleGenerateExtend = async () => {
|
|
28
|
-
await store.generateExtend(
|
|
29
|
-
projectId,
|
|
30
|
-
store.selectedVideo?.url || store.selectedVideo?.filename || "",
|
|
31
|
-
);
|
|
32
|
-
document.body.scrollTop = 99999999999;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// ========== SVG Icons ==========
|
|
36
|
-
|
|
37
|
-
const ExtendIcon = (
|
|
38
|
-
<svg
|
|
39
|
-
width="18"
|
|
40
|
-
height="18"
|
|
41
|
-
viewBox="0 0 24 24"
|
|
42
|
-
fill="none"
|
|
43
|
-
stroke="currentColor"
|
|
44
|
-
strokeWidth="2"
|
|
45
|
-
strokeLinecap="round"
|
|
46
|
-
strokeLinejoin="round"
|
|
47
|
-
>
|
|
48
|
-
<polygon points="23 7 16 12 23 17 23 7" />
|
|
49
|
-
<rect x="1" y="5" width="15" height="14" rx="2" ry="2" />
|
|
50
|
-
<line x1="5" y1="12" x2="11" y2="12" />
|
|
51
|
-
<line x1="8" y1="9" x2="8" y2="15" />
|
|
52
|
-
</svg>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const SparkleIcon = (
|
|
56
|
-
<svg
|
|
57
|
-
width="16"
|
|
58
|
-
height="16"
|
|
59
|
-
viewBox="0 0 24 24"
|
|
60
|
-
fill="none"
|
|
61
|
-
stroke="currentColor"
|
|
62
|
-
strokeWidth="2"
|
|
63
|
-
>
|
|
64
|
-
<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />
|
|
65
|
-
</svg>
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div className="flex flex-col gap-7">
|
|
70
|
-
<div className="flex items-center gap-2">
|
|
71
|
-
<span className="text-tiffany-600">{ExtendIcon}</span>
|
|
72
|
-
<h2 className="text-base font-semibold text-ink-900">
|
|
73
|
-
Extend Video
|
|
74
|
-
</h2>
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
{/* Source video picker */}
|
|
78
|
-
<div className="flex gap-6">
|
|
79
|
-
{/* Video list */}
|
|
80
|
-
<div className="flex-1 min-w-0">
|
|
81
|
-
<label className="block text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
82
|
-
Source Video
|
|
83
|
-
</label>
|
|
84
|
-
{store.projectVideos.length > 0 && (
|
|
85
|
-
<div className="relative mb-2">
|
|
86
|
-
<svg
|
|
87
|
-
className="absolute left-3 top-1/2 -translate-y-1/2 text-ink-500"
|
|
88
|
-
width="14"
|
|
89
|
-
height="14"
|
|
90
|
-
viewBox="0 0 24 24"
|
|
91
|
-
fill="none"
|
|
92
|
-
stroke="currentColor"
|
|
93
|
-
strokeWidth="2"
|
|
94
|
-
strokeLinecap="round"
|
|
95
|
-
strokeLinejoin="round"
|
|
96
|
-
>
|
|
97
|
-
<circle cx="11" cy="11" r="8" />
|
|
98
|
-
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
99
|
-
</svg>
|
|
100
|
-
<input
|
|
101
|
-
type="text"
|
|
102
|
-
placeholder="Filter videos..."
|
|
103
|
-
value={search}
|
|
104
|
-
onChange={(e) => setSearch(e.target.value)}
|
|
105
|
-
className="w-full pl-9 pr-3 py-2 bg-ink-50 border border-ink-200 rounded-2xl text-ink-900 text-sm placeholder-ink-500 focus:outline-none focus:border-tiffany-500 focus:ring-2 focus:ring-tiffany-500/30 transition-all"
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
)}
|
|
109
|
-
{store.projectVideosLoading ? (
|
|
110
|
-
<p className="text-xs text-ink-500 italic py-4">
|
|
111
|
-
Loading videos...
|
|
112
|
-
</p>
|
|
113
|
-
) : store.projectVideos.length === 0 ? (
|
|
114
|
-
<p className="text-xs text-ink-500 italic py-4 border border-dashed border-ink-200 rounded-2xl text-center">
|
|
115
|
-
No videos yet. Generate a video in the "Generate Video" tab.
|
|
116
|
-
</p>
|
|
117
|
-
) : filteredVideos.length === 0 ? (
|
|
118
|
-
<p className="text-xs text-ink-500 italic py-4 border border-dashed border-ink-200 rounded-2xl text-center">
|
|
119
|
-
No videos match "{search}".
|
|
120
|
-
</p>
|
|
121
|
-
) : (
|
|
122
|
-
<div className="border border-ink-200 rounded-2xl overflow-hidden max-h-64 overflow-y-auto">
|
|
123
|
-
{filteredVideos.map((v) => {
|
|
124
|
-
const isSelected = store.selectedVideo?.filename === v.filename;
|
|
125
|
-
return (
|
|
126
|
-
<button
|
|
127
|
-
key={v.filename}
|
|
128
|
-
onClick={() => store.selectVideo(v)}
|
|
129
|
-
disabled={store.extend.generating}
|
|
130
|
-
className={`w-full flex items-center gap-2 px-3 py-2 text-left text-sm transition-colors border-b border-ink-200 last:border-b-0 ${
|
|
131
|
-
isSelected
|
|
132
|
-
? "bg-ink-100 text-ink-900 font-medium"
|
|
133
|
-
: "text-ink-700 hover:bg-ink-100"
|
|
134
|
-
} disabled:opacity-50`}
|
|
135
|
-
>
|
|
136
|
-
<svg
|
|
137
|
-
width="14"
|
|
138
|
-
height="14"
|
|
139
|
-
viewBox="0 0 24 24"
|
|
140
|
-
fill="none"
|
|
141
|
-
stroke="currentColor"
|
|
142
|
-
strokeWidth="2"
|
|
143
|
-
className="shrink-0 text-ink-500"
|
|
144
|
-
>
|
|
145
|
-
<polygon points="23 7 16 12 23 17 23 7" />
|
|
146
|
-
<rect x="1" y="5" width="15" height="14" rx="2" ry="2" />
|
|
147
|
-
</svg>
|
|
148
|
-
<span className="truncate">{v.filename}</span>
|
|
149
|
-
</button>
|
|
150
|
-
);
|
|
151
|
-
})}
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
154
|
-
</div>
|
|
155
|
-
|
|
156
|
-
{/* Preview box */}
|
|
157
|
-
{store.selectedVideo && (
|
|
158
|
-
<div className="w-1/2 shrink-0">
|
|
159
|
-
<label className="block text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
160
|
-
Preview
|
|
161
|
-
</label>
|
|
162
|
-
<div className="relative rounded-2xl overflow-hidden border border-ink-200 bg-black aspect-video">
|
|
163
|
-
<video
|
|
164
|
-
src={
|
|
165
|
-
store.selectedVideo.url.startsWith("/")
|
|
166
|
-
? `http://localhost:${(window as any).PORT}${store.selectedVideo.url}`
|
|
167
|
-
: store.selectedVideo.url
|
|
168
|
-
}
|
|
169
|
-
muted={false}
|
|
170
|
-
playsInline
|
|
171
|
-
controls
|
|
172
|
-
className="w-full h-full object-contain"
|
|
173
|
-
/>
|
|
174
|
-
</div>
|
|
175
|
-
<p className="text-[10px] text-tiffany-600 mt-1 truncate">
|
|
176
|
-
{store.selectedVideo.filename}
|
|
177
|
-
</p>
|
|
178
|
-
</div>
|
|
179
|
-
)}
|
|
180
|
-
</div>
|
|
181
|
-
|
|
182
|
-
{/* Prompt */}
|
|
183
|
-
<div>
|
|
184
|
-
<label className="block text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
185
|
-
Continue the Scene Prompt
|
|
186
|
-
</label>
|
|
187
|
-
<textarea
|
|
188
|
-
value={store.extend.prompt}
|
|
189
|
-
onChange={(e) => store.setExtendPrompt(e.target.value)}
|
|
190
|
-
placeholder="Describe how the video should continue, e.g. the camera holds, the motion continues naturally..."
|
|
191
|
-
rows={4}
|
|
192
|
-
disabled={store.extend.generating}
|
|
193
|
-
className="w-full px-4 py-3 bg-ink-50 border border-ink-200 rounded-2xl text-ink-900 text-sm placeholder-ink-500/40 focus:outline-none focus:border-tiffany-500 focus:ring-2 focus:ring-tiffany-500/30 transition-all resize-none disabled:opacity-50"
|
|
194
|
-
/>
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
{/* Duration (seconds) */}
|
|
198
|
-
<div>
|
|
199
|
-
<label className="block text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
200
|
-
Duration (seconds)
|
|
201
|
-
</label>
|
|
202
|
-
<div className="flex flex-wrap gap-2">
|
|
203
|
-
{[0.5, 1, 2, 3, 5, 7.5, 10].map((d) => (
|
|
204
|
-
<button
|
|
205
|
-
key={d}
|
|
206
|
-
onClick={() => store.setExtendDuration(d)}
|
|
207
|
-
disabled={store.extend.generating}
|
|
208
|
-
className={`px-4 py-1.5 text-xs font-medium rounded-xl border transition-all ${
|
|
209
|
-
store.extend.extendDuration === d
|
|
210
|
-
? "bg-ink-100 border-ink-300 text-ink-800"
|
|
211
|
-
: "bg-white border-ink-200 text-ink-600 hover:border-ink-300"
|
|
212
|
-
} disabled:opacity-50`}
|
|
213
|
-
>
|
|
214
|
-
{d}s
|
|
215
|
-
</button>
|
|
216
|
-
))}
|
|
217
|
-
</div>
|
|
218
|
-
<p className="text-xs text-ink-600/50 mt-1.5">
|
|
219
|
-
{store.extend.extendFrames} frames ({store.extend.extendDuration}s ×
|
|
220
|
-
24 fps + 1)
|
|
221
|
-
</p>
|
|
222
|
-
</div>
|
|
223
|
-
|
|
224
|
-
{/* Generate / Stop button */}
|
|
225
|
-
{store.extend.generating ? (
|
|
226
|
-
<div className="flex items-center gap-3">
|
|
227
|
-
<div className="flex items-center gap-2 flex-1 px-4 py-3 bg-ink-50 border border-ink-200 rounded-2xl">
|
|
228
|
-
<svg
|
|
229
|
-
className="animate-spin text-tiffany-600"
|
|
230
|
-
width="16"
|
|
231
|
-
height="16"
|
|
232
|
-
viewBox="0 0 24 24"
|
|
233
|
-
fill="none"
|
|
234
|
-
stroke="currentColor"
|
|
235
|
-
strokeWidth="2"
|
|
236
|
-
>
|
|
237
|
-
<circle cx="12" cy="12" r="10" strokeOpacity="0.25" />
|
|
238
|
-
<path d="M12 2a10 10 0 0 1 10 10" strokeOpacity="0.75" />
|
|
239
|
-
</svg>
|
|
240
|
-
<span className="text-sm font-medium text-ink-700">
|
|
241
|
-
Extending...
|
|
242
|
-
</span>
|
|
243
|
-
</div>
|
|
244
|
-
<button
|
|
245
|
-
onClick={() => store.cancelGenerate()}
|
|
246
|
-
className="flex items-center justify-center gap-1.5 px-5 py-3 bg-red-500 hover:bg-red-600 active:bg-red-700 text-white text-sm font-semibold rounded-2xl transition-all duration-150 shadow-sm"
|
|
247
|
-
>
|
|
248
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
|
249
|
-
<rect x="4" y="4" width="16" height="16" rx="2" />
|
|
250
|
-
</svg>
|
|
251
|
-
Stop
|
|
252
|
-
</button>
|
|
253
|
-
</div>
|
|
254
|
-
) : (
|
|
255
|
-
<button
|
|
256
|
-
onClick={handleGenerateExtend}
|
|
257
|
-
disabled={!store.selectedVideo || !store.extend.prompt.trim()}
|
|
258
|
-
className="flex items-center justify-center gap-2 w-full px-4 py-3 bg-tiffany-500 hover:bg-tiffany-600 active:bg-tiffany-700 disabled:bg-ink-200 disabled:text-ink-500 text-ink-950 text-sm font-semibold rounded-2xl transition-all duration-150 shadow-sm hover:shadow-md disabled:shadow-none"
|
|
259
|
-
>
|
|
260
|
-
{SparkleIcon}
|
|
261
|
-
Extend Video
|
|
262
|
-
</button>
|
|
263
|
-
)}
|
|
264
|
-
|
|
265
|
-
{/* Error */}
|
|
266
|
-
{store.extend.error && (
|
|
267
|
-
<div className="p-5 bg-red-50 border border-red-200 rounded-2xl text-red-600 text-sm">
|
|
268
|
-
{store.extend.error}
|
|
269
|
-
</div>
|
|
270
|
-
)}
|
|
271
|
-
|
|
272
|
-
{/* Logs */}
|
|
273
|
-
{store.extend.logs.length > 0 && (
|
|
274
|
-
<div
|
|
275
|
-
ref={extendLogRef}
|
|
276
|
-
id="extend-logs"
|
|
277
|
-
className="p-5 bg-ink-50 border border-ink-200 rounded-2xl max-h-40 overflow-y-auto"
|
|
278
|
-
>
|
|
279
|
-
<p className="text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
280
|
-
Logs
|
|
281
|
-
</p>
|
|
282
|
-
<pre className="text-xs text-ink-600 font-mono whitespace-pre-wrap">
|
|
283
|
-
{store.extend.logs.join("\n")}
|
|
284
|
-
</pre>
|
|
285
|
-
</div>
|
|
286
|
-
)}
|
|
287
|
-
|
|
288
|
-
{/* Result */}
|
|
289
|
-
{store.extend.result && (
|
|
290
|
-
<div>
|
|
291
|
-
<label className="block text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
292
|
-
Extended Video
|
|
293
|
-
</label>
|
|
294
|
-
<div className="relative rounded-2xl overflow-hidden border border-ink-200 shadow-card bg-black w-[500px]">
|
|
295
|
-
<video
|
|
296
|
-
src={store.extend.result}
|
|
297
|
-
controls
|
|
298
|
-
className="w-full h-auto"
|
|
299
|
-
/>
|
|
300
|
-
</div>
|
|
301
|
-
</div>
|
|
302
|
-
)}
|
|
303
|
-
</div>
|
|
304
|
-
);
|
|
305
|
-
}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { useGenerationStore, type ProjectVideo } from "../../stores/generationStore";
|
|
3
|
-
|
|
4
|
-
const API_BASE = `http://localhost:${(window as any).PORT}`;
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
projectId: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** Seek the video to `time` and draw its current frame into a PNG data URL. */
|
|
11
|
-
async function captureFrameAt(
|
|
12
|
-
video: HTMLVideoElement,
|
|
13
|
-
time: number,
|
|
14
|
-
): Promise<string> {
|
|
15
|
-
await new Promise<void>((resolve) => {
|
|
16
|
-
if (Math.abs(video.currentTime - time) < 0.001 && !video.seeking) {
|
|
17
|
-
resolve();
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const cleanup = () => {
|
|
21
|
-
clearTimeout(timer);
|
|
22
|
-
video.removeEventListener("seeked", onSeeked);
|
|
23
|
-
};
|
|
24
|
-
const onSeeked = () => {
|
|
25
|
-
cleanup();
|
|
26
|
-
resolve();
|
|
27
|
-
};
|
|
28
|
-
const timer = setTimeout(onSeeked, 1500);
|
|
29
|
-
video.addEventListener("seeked", onSeeked);
|
|
30
|
-
video.currentTime = time;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const canvas = document.createElement("canvas");
|
|
34
|
-
canvas.width = video.videoWidth;
|
|
35
|
-
canvas.height = video.videoHeight;
|
|
36
|
-
const ctx = canvas.getContext("2d");
|
|
37
|
-
if (!ctx) throw new Error("Canvas not supported");
|
|
38
|
-
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
39
|
-
return canvas.toDataURL("image/png");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default function ExtractImageTab({ projectId }: Props) {
|
|
43
|
-
const gen = useGenerationStore();
|
|
44
|
-
|
|
45
|
-
const videoRef = useRef<HTMLVideoElement>(null);
|
|
46
|
-
|
|
47
|
-
const [selected, setSelected] = useState<ProjectVideo | null>(null);
|
|
48
|
-
const [duration, setDuration] = useState(0);
|
|
49
|
-
const [time, setTime] = useState(0);
|
|
50
|
-
const [extracting, setExtracting] = useState(false);
|
|
51
|
-
const [preview, setPreview] = useState<string | null>(null);
|
|
52
|
-
const [savedName, setSavedName] = useState<string | null>(null);
|
|
53
|
-
const [error, setError] = useState<string | null>(null);
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
gen.fetchProjectVideos(projectId);
|
|
57
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
-
}, [projectId]);
|
|
59
|
-
|
|
60
|
-
const selectVideo = (v: ProjectVideo) => {
|
|
61
|
-
setSelected(v);
|
|
62
|
-
setPreview(null);
|
|
63
|
-
setSavedName(null);
|
|
64
|
-
setDuration(0);
|
|
65
|
-
setTime(0);
|
|
66
|
-
setError(null);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const onLoadedMetadata = (e: React.SyntheticEvent<HTMLVideoElement>) => {
|
|
70
|
-
const d = e.currentTarget.duration;
|
|
71
|
-
setDuration(Number.isFinite(d) ? d : 0);
|
|
72
|
-
setTime(0);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const handleExtract = async () => {
|
|
76
|
-
const video = videoRef.current;
|
|
77
|
-
if (!video) return;
|
|
78
|
-
setExtracting(true);
|
|
79
|
-
setError(null);
|
|
80
|
-
setPreview(null);
|
|
81
|
-
setSavedName(null);
|
|
82
|
-
try {
|
|
83
|
-
const dataUrl = await captureFrameAt(video, time);
|
|
84
|
-
setPreview(dataUrl);
|
|
85
|
-
|
|
86
|
-
const res = await fetch(`${API_BASE}/api/extracted-frames`, {
|
|
87
|
-
method: "POST",
|
|
88
|
-
headers: { "Content-Type": "application/json" },
|
|
89
|
-
body: JSON.stringify({
|
|
90
|
-
image: dataUrl,
|
|
91
|
-
filename: `frame-${Date.now()}.png`,
|
|
92
|
-
projectId,
|
|
93
|
-
}),
|
|
94
|
-
});
|
|
95
|
-
if (!res.ok) throw new Error(await res.text());
|
|
96
|
-
const data = await res.json();
|
|
97
|
-
setSavedName(data.filename as string);
|
|
98
|
-
} catch (e) {
|
|
99
|
-
setError(String(e));
|
|
100
|
-
} finally {
|
|
101
|
-
setExtracting(false);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// ========== SVG Icons ==========
|
|
106
|
-
|
|
107
|
-
const VideoIcon = (
|
|
108
|
-
<svg
|
|
109
|
-
width="18"
|
|
110
|
-
height="18"
|
|
111
|
-
viewBox="0 0 24 24"
|
|
112
|
-
fill="none"
|
|
113
|
-
stroke="currentColor"
|
|
114
|
-
strokeWidth="2"
|
|
115
|
-
>
|
|
116
|
-
<polygon points="23 7 16 12 23 17 23 7" />
|
|
117
|
-
<rect x="1" y="5" width="15" height="14" rx="2" ry="2" />
|
|
118
|
-
</svg>
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const CameraIcon = (
|
|
122
|
-
<svg
|
|
123
|
-
width="14"
|
|
124
|
-
height="14"
|
|
125
|
-
viewBox="0 0 24 24"
|
|
126
|
-
fill="none"
|
|
127
|
-
stroke="currentColor"
|
|
128
|
-
strokeWidth="2"
|
|
129
|
-
strokeLinecap="round"
|
|
130
|
-
strokeLinejoin="round"
|
|
131
|
-
>
|
|
132
|
-
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" />
|
|
133
|
-
<circle cx="12" cy="13" r="4" />
|
|
134
|
-
</svg>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<div className="flex flex-col gap-7">
|
|
139
|
-
<div className="flex items-center gap-2">
|
|
140
|
-
<span className="text-tiffany-600">{CameraIcon}</span>
|
|
141
|
-
<h2 className="text-base font-semibold text-ink-900">
|
|
142
|
-
Image Extract from Video
|
|
143
|
-
</h2>
|
|
144
|
-
</div>
|
|
145
|
-
|
|
146
|
-
{/* Video picker */}
|
|
147
|
-
<div>
|
|
148
|
-
<label className="block text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
149
|
-
Videos
|
|
150
|
-
</label>
|
|
151
|
-
{gen.projectVideosLoading ? (
|
|
152
|
-
<p className="text-xs text-ink-500 italic py-4 text-center">
|
|
153
|
-
Loading videos...
|
|
154
|
-
</p>
|
|
155
|
-
) : gen.projectVideos.length === 0 ? (
|
|
156
|
-
<p className="text-xs text-ink-500 italic py-4 text-center border border-dashed border-ink-200 rounded-2xl">
|
|
157
|
-
No generated videos yet.
|
|
158
|
-
</p>
|
|
159
|
-
) : (
|
|
160
|
-
<ul className="divide-y divide-ink-200 border border-ink-200 rounded-2xl overflow-hidden max-h-48 overflow-y-auto">
|
|
161
|
-
{gen.projectVideos.map((v) => (
|
|
162
|
-
<li key={v.filename}>
|
|
163
|
-
<button
|
|
164
|
-
onClick={() => selectVideo(v)}
|
|
165
|
-
className={`w-full flex items-center gap-2 px-3 py-2 text-left text-xs transition-colors ${
|
|
166
|
-
selected?.filename === v.filename
|
|
167
|
-
? "bg-ink-100 text-ink-800"
|
|
168
|
-
: "text-ink-600 hover:bg-ink-100"
|
|
169
|
-
}`}
|
|
170
|
-
>
|
|
171
|
-
<span className="text-ink-500">{VideoIcon}</span>
|
|
172
|
-
<span className="truncate">{v.filename}</span>
|
|
173
|
-
</button>
|
|
174
|
-
</li>
|
|
175
|
-
))}
|
|
176
|
-
</ul>
|
|
177
|
-
)}
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
{selected && (
|
|
181
|
-
<div className="flex flex-col gap-6">
|
|
182
|
-
<video
|
|
183
|
-
ref={videoRef}
|
|
184
|
-
src={selected.url}
|
|
185
|
-
crossOrigin="anonymous"
|
|
186
|
-
controls
|
|
187
|
-
onLoadedMetadata={onLoadedMetadata}
|
|
188
|
-
className="w-full max-h-64 rounded-2xl border border-ink-200 bg-black"
|
|
189
|
-
/>
|
|
190
|
-
|
|
191
|
-
<div>
|
|
192
|
-
<label className="block text-xs font-semibold text-ink-700 uppercase tracking-wider mb-2">
|
|
193
|
-
Moment ({time.toFixed(2)}s / {duration.toFixed(2)}s)
|
|
194
|
-
</label>
|
|
195
|
-
<input
|
|
196
|
-
type="range"
|
|
197
|
-
min={0}
|
|
198
|
-
max={duration || 0}
|
|
199
|
-
step={0.05}
|
|
200
|
-
value={time}
|
|
201
|
-
onChange={(e) => {
|
|
202
|
-
const t = Number(e.target.value);
|
|
203
|
-
setTime(t);
|
|
204
|
-
if (videoRef.current) videoRef.current.currentTime = t;
|
|
205
|
-
}}
|
|
206
|
-
disabled={!duration}
|
|
207
|
-
className="w-full accent-tiffany-500"
|
|
208
|
-
/>
|
|
209
|
-
</div>
|
|
210
|
-
|
|
211
|
-
<div className="flex items-center gap-2">
|
|
212
|
-
<button
|
|
213
|
-
onClick={handleExtract}
|
|
214
|
-
disabled={extracting || !duration}
|
|
215
|
-
className="flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-xl bg-tiffany-500 hover:bg-tiffany-600 disabled:bg-ink-200 disabled:text-ink-500 text-ink-950 transition-colors"
|
|
216
|
-
>
|
|
217
|
-
{CameraIcon}
|
|
218
|
-
Extract Frame
|
|
219
|
-
</button>
|
|
220
|
-
{extracting && (
|
|
221
|
-
<span className="text-xs text-ink-600 italic">
|
|
222
|
-
Extracting...
|
|
223
|
-
</span>
|
|
224
|
-
)}
|
|
225
|
-
</div>
|
|
226
|
-
|
|
227
|
-
{error && <p className="text-xs text-red-600">{error}</p>}
|
|
228
|
-
|
|
229
|
-
{preview && (
|
|
230
|
-
<div className="flex flex-col gap-3">
|
|
231
|
-
<div className="rounded-2xl overflow-hidden border border-ink-200 inline-block bg-ink-100">
|
|
232
|
-
<img
|
|
233
|
-
src={preview}
|
|
234
|
-
alt="extracted"
|
|
235
|
-
className="max-h-72 object-contain"
|
|
236
|
-
/>
|
|
237
|
-
</div>
|
|
238
|
-
{savedName && (
|
|
239
|
-
<p className="text-xs text-emerald-600">
|
|
240
|
-
Saved as {savedName} in extracted-frames/{projectId}
|
|
241
|
-
</p>
|
|
242
|
-
)}
|
|
243
|
-
</div>
|
|
244
|
-
)}
|
|
245
|
-
</div>
|
|
246
|
-
)}
|
|
247
|
-
</div>
|
|
248
|
-
);
|
|
249
|
-
}
|