blob: 2679a26ea2e756510dde36781edaaf4fa15fea46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package cli
import (
"context"
"fmt"
"codeberg.org/snonux/totalrecall/internal/video"
)
// GenerateSelectedVideos is the CLI runner that animates gallery PNG files
// into MP4 clips using Google's Veo model. It processes pages sequentially
// (Veo generation is slow and API quotas make parallelism impractical).
//
// apiKey is the Google/Gemini API key passed by the caller.
// selected is the list of gallery page numbers to process (from PromptForGalleryVideos).
// outputDir is both the directory that contains the gallery PNGs and the
// destination for the resulting MP4 files (written next to the PNGs).
//
// Each page prints a "Generating…" line before the API call and a "Video saved:"
// line with the output path on success. The function stops and returns on the
// first error so callers can log it without silently skipping pages.
func GenerateSelectedVideos(apiKey string, selected []int, outputDir string) error {
if len(selected) == 0 {
return nil
}
gen, err := video.NewVeoGenerator(apiKey)
if err != nil {
return fmt.Errorf("cli: initialising Veo generator: %w", err)
}
ctx := context.Background()
for _, pageNum := range selected {
fmt.Printf("Generating video for gallery page %d...\n", pageNum)
mp4Path, err := gen.GenerateVideoFromGallery(ctx, outputDir, outputDir, pageNum)
if err != nil {
return fmt.Errorf("cli: generating video for page %d: %w", pageNum, err)
}
fmt.Printf("Video saved: %s\n", mp4Path)
}
return nil
}
|