feat(video): add video upload with remux/transcode playback

Add video as a media kind in photos: streaming upload with per-kind
limits, ffprobe metadata, poster frame reusing the image variant
pipeline, and a playback object (remux when web-compatible, else
h264/yuv420p/aac transcode). Video jobs run on a separate pool with a
long lease. Frontend gains a video viewer, grid badge/duration and
video upload.
This commit is contained in:
iu
2026-10-11 20:37:53 +03:00
parent d059d042f0
commit d38ede0201
52 changed files with 2717 additions and 82 deletions
+56
View File
@@ -176,3 +176,59 @@ func TestLoadLog(t *testing.T) {
}
})
}
func TestLoadUploadAndVideo(t *testing.T) {
t.Run("defaults", func(t *testing.T) {
setRequiredEnv(t)
cfg, err := Load()
if err != nil {
t.Fatalf("load: %v", err)
}
if cfg.Upload.ImageMaxBytes != 100<<20 {
t.Fatalf("image max = %d, want 100MiB", cfg.Upload.ImageMaxBytes)
}
if cfg.Upload.VideoMaxBytes != 2<<30 {
t.Fatalf("video max = %d, want 2GiB", cfg.Upload.VideoMaxBytes)
}
if cfg.Video.FFmpegPath != "ffmpeg" || cfg.Video.FFprobePath != "ffprobe" {
t.Fatalf("tool paths = %+v", cfg.Video)
}
if cfg.Video.TranscodeConcurrency != 1 {
t.Fatalf("transcode concurrency = %d, want 1", cfg.Video.TranscodeConcurrency)
}
})
t.Run("custom values", func(t *testing.T) {
setRequiredEnv(t)
t.Setenv("IMAGE_MAX_UPLOAD_SIZE", "50MB")
t.Setenv("VIDEO_MAX_UPLOAD_SIZE", "3GB")
t.Setenv("FFMPEG_PATH", "/usr/bin/ffmpeg")
t.Setenv("FFPROBE_PATH", "/usr/bin/ffprobe")
t.Setenv("VIDEO_TRANSCODE_CONCURRENCY", "2")
t.Setenv("VIDEO_TEMP_DIR", "/var/tmp/galo")
cfg, err := Load()
if err != nil {
t.Fatalf("load: %v", err)
}
if cfg.Upload.ImageMaxBytes != 50<<20 {
t.Fatalf("image max = %d, want 50MiB", cfg.Upload.ImageMaxBytes)
}
if cfg.Upload.VideoMaxBytes != 3<<30 {
t.Fatalf("video max = %d, want 3GiB", cfg.Upload.VideoMaxBytes)
}
if cfg.Video.FFmpegPath != "/usr/bin/ffmpeg" || cfg.Video.TranscodeConcurrency != 2 {
t.Fatalf("video = %+v", cfg.Video)
}
if cfg.Video.TempDir != "/var/tmp/galo" {
t.Fatalf("temp dir = %q", cfg.Video.TempDir)
}
})
t.Run("invalid size", func(t *testing.T) {
setRequiredEnv(t)
t.Setenv("VIDEO_MAX_UPLOAD_SIZE", "lots")
if _, err := Load(); err == nil {
t.Fatal("expected error for invalid VIDEO_MAX_UPLOAD_SIZE")
}
})
}