Documentation
¶
Index ¶
- func ValidateExternalURL(rawURL string) error
- func ValidateGenerateRequest(req *GenerateRequest) error
- type AnalyzeRequest
- type AnalyzeResponse
- type BoundingBox
- type DetectedObject
- type FrameAnalysis
- type GeminiConfig
- type GeminiProvider
- func (p *GeminiProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *GeminiProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *GeminiProvider) Name() string
- func (p *GeminiProvider) SupportedFormats() []VideoFormat
- func (p *GeminiProvider) SupportsGeneration() bool
- type GenerateRequest
- type GenerateResponse
- type KlingConfig
- type KlingProvider
- func (p *KlingProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *KlingProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *KlingProvider) Name() string
- func (p *KlingProvider) SupportedFormats() []VideoFormat
- func (p *KlingProvider) SupportsGeneration() bool
- type LumaConfig
- type LumaProvider
- func (p *LumaProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *LumaProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *LumaProvider) Name() string
- func (p *LumaProvider) SupportedFormats() []VideoFormat
- func (p *LumaProvider) SupportsGeneration() bool
- type MiniMaxVideoConfig
- type MiniMaxVideoProvider
- func (p *MiniMaxVideoProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *MiniMaxVideoProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *MiniMaxVideoProvider) Name() string
- func (p *MiniMaxVideoProvider) SupportedFormats() []VideoFormat
- func (p *MiniMaxVideoProvider) SupportsGeneration() bool
- type Provider
- type RunwayConfig
- type RunwayProvider
- func (p *RunwayProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *RunwayProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *RunwayProvider) Name() string
- func (p *RunwayProvider) SupportedFormats() []VideoFormat
- func (p *RunwayProvider) SupportsGeneration() bool
- type SeedanceConfig
- type SeedanceProvider
- func (p *SeedanceProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *SeedanceProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *SeedanceProvider) Name() string
- func (p *SeedanceProvider) SupportedFormats() []VideoFormat
- func (p *SeedanceProvider) SupportsGeneration() bool
- type SoraConfig
- type SoraProvider
- func (p *SoraProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *SoraProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *SoraProvider) Name() string
- func (p *SoraProvider) SupportedFormats() []VideoFormat
- func (p *SoraProvider) SupportsGeneration() bool
- type VeoConfig
- type VeoProvider
- func (p *VeoProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
- func (p *VeoProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
- func (p *VeoProvider) Name() string
- func (p *VeoProvider) SupportedFormats() []VideoFormat
- func (p *VeoProvider) SupportsGeneration() bool
- type VideoData
- type VideoFormat
- type VideoUsage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateExternalURL ¶
ValidateExternalURL checks that a URL is a valid external HTTP(S) URL, rejecting file://, internal IPs, and loopback addresses (SSRF protection).
func ValidateGenerateRequest ¶
func ValidateGenerateRequest(req *GenerateRequest) error
ValidateGenerateRequest validates common fields of a GenerateRequest. Returns an error if the request is invalid.
Types ¶
type AnalyzeRequest ¶
type AnalyzeRequest struct {
VideoURL string `json:"video_url,omitempty"`
VideoData string `json:"video_data,omitempty"` // Base64 encoded
VideoFormat VideoFormat `json:"video_format,omitempty"`
Prompt string `json:"prompt"`
Model string `json:"model,omitempty"`
MaxFrames int `json:"max_frames,omitempty"` // Max frames to analyze
Interval float64 `json:"interval,omitempty"` // Frame interval in seconds
StartTime float64 `json:"start_time,omitempty"` // Start time in seconds
EndTime float64 `json:"end_time,omitempty"` // End time in seconds
Metadata map[string]string `json:"metadata,omitempty"`
}
AnalyzeRequest 表示视频分析请求.
type AnalyzeResponse ¶
type AnalyzeResponse struct {
Provider string `json:"provider"`
Model string `json:"model"`
Content string `json:"content"`
Frames []FrameAnalysis `json:"frames,omitempty"`
Duration float64 `json:"duration,omitempty"`
Usage VideoUsage `json:"usage,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AnalyzeResponse 表示视频分析的响应.
type BoundingBox ¶
type BoundingBox struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
}
BoundingBox 表示帧中的对象位置.
type DetectedObject ¶
type DetectedObject struct {
Label string `json:"label"`
Confidence float64 `json:"confidence"`
BoundingBox *BoundingBox `json:"bounding_box,omitempty"`
}
DetectedObject 表示在帧中检测到的对象.
type FrameAnalysis ¶
type FrameAnalysis struct {
Timestamp float64 `json:"timestamp"`
Description string `json:"description,omitempty"`
Objects []DetectedObject `json:"objects,omitempty"`
Text string `json:"text,omitempty"` // OCR text
Metadata map[string]string `json:"metadata,omitempty"`
}
FrameAnalysis 表示单帧的分析结果.
type GeminiConfig ¶
type GeminiConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
ProjectID string `json:"project_id,omitempty" yaml:"project_id,omitempty"`
Location string `json:"location,omitempty" yaml:"location,omitempty"`
}
GeminiConfig configures the Google Gemini video understanding provider. It embeds providers.BaseProviderConfig to reuse APIKey, Model, and Timeout. ProjectID and Location remain Gemini-specific fields.
func DefaultGeminiConfig ¶
func DefaultGeminiConfig() GeminiConfig
DefaultGeminiConfig returns the default Gemini video configuration.
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
GeminiProvider analyzes video content using Google Gemini.
func NewGeminiProvider ¶
func NewGeminiProvider(cfg GeminiConfig, logger *zap.Logger) *GeminiProvider
NewGeminiProvider creates a new Gemini video provider.
func (*GeminiProvider) Analyze ¶
func (p *GeminiProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
Analyze processes video understanding requests with Gemini multimodal capabilities.
func (*GeminiProvider) Generate ¶
func (p *GeminiProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate is not supported by the Gemini video provider.
func (*GeminiProvider) Name ¶
func (p *GeminiProvider) Name() string
func (*GeminiProvider) SupportedFormats ¶
func (p *GeminiProvider) SupportedFormats() []VideoFormat
func (*GeminiProvider) SupportsGeneration ¶
func (p *GeminiProvider) SupportsGeneration() bool
type GenerateRequest ¶
type GenerateRequest struct {
Prompt string `json:"prompt"`
NegativePrompt string `json:"negative_prompt,omitempty"`
Mode types.VideoGenerationMode `json:"mode,omitempty"`
Model string `json:"model,omitempty"`
Duration float64 `json:"duration,omitempty"` // Duration in seconds
AspectRatio string `json:"aspect_ratio,omitempty"` // 16:9, 9:16, 1:1
Resolution string `json:"resolution,omitempty"` // 720p, 1080p
FPS int `json:"fps,omitempty"`
Seed int64 `json:"seed,omitempty"`
Image string `json:"image,omitempty"` // Image-to-video base64
ImageURL string `json:"image_url,omitempty"` // Image-to-video URL
ResponseFormat string `json:"response_format,omitempty"` // url, b64_json
Metadata map[string]string `json:"metadata,omitempty"`
}
GenerateRequest 表示视频生成请求.
type GenerateResponse ¶
type GenerateResponse struct {
Provider string `json:"provider"`
Model string `json:"model"`
Videos []VideoData `json:"videos"`
Usage VideoUsage `json:"usage,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
GenerateResponse 表示视频生成响应.
type KlingConfig ¶
type KlingConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
}
KlingConfig configures the Kling AI video generation provider.
func DefaultKlingConfig ¶
func DefaultKlingConfig() KlingConfig
DefaultKlingConfig returns the default Kling configuration.
type KlingProvider ¶
type KlingProvider struct {
// contains filtered or unexported fields
}
KlingProvider implements video generation using Kling AI (可灵). 官方异步流程:提交任务返回 task_id,通过轮询 GET /v1/videos/{task_id} 或配置 callback_url 获取结果。 参考:https://app.klingai.com/cn/dev/document-api
func NewKlingProvider ¶
func NewKlingProvider(cfg KlingConfig, logger *zap.Logger) *KlingProvider
NewKlingProvider creates a new Kling AI video provider.
func (*KlingProvider) Analyze ¶
func (p *KlingProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
Analyze is not supported by the Kling provider.
func (*KlingProvider) Generate ¶
func (p *KlingProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate creates a video using Kling AI.
func (*KlingProvider) Name ¶
func (p *KlingProvider) Name() string
func (*KlingProvider) SupportedFormats ¶
func (p *KlingProvider) SupportedFormats() []VideoFormat
func (*KlingProvider) SupportsGeneration ¶
func (p *KlingProvider) SupportsGeneration() bool
type LumaConfig ¶
type LumaConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
}
LumaConfig configures the Luma AI Dream Machine video generation provider.
func DefaultLumaConfig ¶
func DefaultLumaConfig() LumaConfig
DefaultLumaConfig returns the default Luma configuration.
type LumaProvider ¶
type LumaProvider struct {
// contains filtered or unexported fields
}
LumaProvider implements video generation using Luma AI Dream Machine (Ray 2). 官方端点(可被配置 BaseURL 覆盖):Base https://api.lumalabs.ai POST /dream-machine/v1/generations(提交)→ GET /dream-machine/v1/generations/{id}(轮询)
func NewLumaProvider ¶
func NewLumaProvider(cfg LumaConfig, logger *zap.Logger) *LumaProvider
NewLumaProvider creates a new Luma AI video provider.
func (*LumaProvider) Analyze ¶
func (p *LumaProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
Analyze is not supported by the Luma provider.
func (*LumaProvider) Generate ¶
func (p *LumaProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate creates a video using Luma AI Dream Machine. Endpoint: POST /dream-machine/v1/generations Auth: Bearer token
func (*LumaProvider) Name ¶
func (p *LumaProvider) Name() string
func (*LumaProvider) SupportedFormats ¶
func (p *LumaProvider) SupportedFormats() []VideoFormat
func (*LumaProvider) SupportsGeneration ¶
func (p *LumaProvider) SupportsGeneration() bool
type MiniMaxVideoConfig ¶
type MiniMaxVideoConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
}
MiniMaxVideoConfig configures the MiniMax Hailuo video generation provider.
func DefaultMiniMaxVideoConfig ¶
func DefaultMiniMaxVideoConfig() MiniMaxVideoConfig
DefaultMiniMaxVideoConfig returns the default MiniMax video configuration.
type MiniMaxVideoProvider ¶
type MiniMaxVideoProvider struct {
// contains filtered or unexported fields
}
MiniMaxVideoProvider implements video generation using MiniMax Hailuo AI. 官方端点(可被配置 BaseURL 覆盖):Base https://api.minimax.chat POST /v1/video_generation(提交)→ GET /v1/query/video_generation?task_id= (轮询)→ GET /v1/files/retrieve?file_id= (取下载 URL)
func NewMiniMaxVideoProvider ¶
func NewMiniMaxVideoProvider(cfg MiniMaxVideoConfig, logger *zap.Logger) *MiniMaxVideoProvider
NewMiniMaxVideoProvider creates a new MiniMax video provider.
func (*MiniMaxVideoProvider) Analyze ¶
func (p *MiniMaxVideoProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
Analyze is not supported by the MiniMax video provider.
func (*MiniMaxVideoProvider) Generate ¶
func (p *MiniMaxVideoProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate creates a video using MiniMax Hailuo AI.
func (*MiniMaxVideoProvider) Name ¶
func (p *MiniMaxVideoProvider) Name() string
func (*MiniMaxVideoProvider) SupportedFormats ¶
func (p *MiniMaxVideoProvider) SupportedFormats() []VideoFormat
func (*MiniMaxVideoProvider) SupportsGeneration ¶
func (p *MiniMaxVideoProvider) SupportsGeneration() bool
type Provider ¶
type Provider interface {
// Analyze 处理和理解视频内容.
Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
// Generate 从文本/图像提示生成视频.
Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
// Name 返回提供者名称.
Name() string
// SupportedFormats 返回支持用于分析的视频格式.
SupportedFormats() []VideoFormat
// SupportsGeneration 返回提供者是否支持视频生成.
SupportsGeneration() bool
}
Provider 定义视频处理提供者接口.
func NewProvider ¶
NewProvider creates a video provider by name using the provided config. The cfg argument accepts either a concrete config value (e.g. SoraConfig), a pointer to that config type, or nil to use package defaults.
type RunwayConfig ¶
type RunwayConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
}
RunwayConfig configures the Runway ML video generation provider.
func DefaultRunwayConfig ¶
func DefaultRunwayConfig() RunwayConfig
DefaultRunwayConfig returns the default Runway configuration.
type RunwayProvider ¶
type RunwayProvider struct {
// contains filtered or unexported fields
}
Runway Provider执行视频生成,使用Runway ML Gen-4. 官方端点(可被配置 BaseURL 覆盖):Base https://api.runwayml.com POST /v1/image_to_video(提交)→ GET /v1/tasks/{id}(轮询) API 文档: https://docs.dev.runwayml.com/api/
func NewRunwayProvider ¶
func NewRunwayProvider(cfg RunwayConfig, logger *zap.Logger) *RunwayProvider
NewRunway Provider创建了新的跑道视频提供商.
func (*RunwayProvider) Analyze ¶
func (p *RunwayProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
分析不由跑道支持.
func (*RunwayProvider) Generate ¶
func (p *RunwayProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
利用跑道Gen-4生成视频. 终点: POST /v1/image to video Auth: 熊克令牌 + X- Runway-Version 信头
func (*RunwayProvider) Name ¶
func (p *RunwayProvider) Name() string
func (*RunwayProvider) SupportedFormats ¶
func (p *RunwayProvider) SupportedFormats() []VideoFormat
func (*RunwayProvider) SupportsGeneration ¶
func (p *RunwayProvider) SupportsGeneration() bool
type SeedanceConfig ¶ added in v1.6.1
type SeedanceConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
}
SeedanceConfig configures the Seedance (即梦 / ByteDance) video generation provider.
func DefaultSeedanceConfig ¶ added in v1.6.1
func DefaultSeedanceConfig() SeedanceConfig
DefaultSeedanceConfig returns the default Seedance (即梦) configuration.
type SeedanceProvider ¶ added in v1.6.1
type SeedanceProvider struct {
// contains filtered or unexported fields
}
SeedanceProvider implements video generation using Seedance (即梦 / ByteDance).
func NewSeedanceProvider ¶ added in v1.6.1
func NewSeedanceProvider(cfg SeedanceConfig, logger *zap.Logger) *SeedanceProvider
NewSeedanceProvider creates a new Seedance video provider.
func (*SeedanceProvider) Analyze ¶ added in v1.6.1
func (p *SeedanceProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
Analyze is not supported.
func (*SeedanceProvider) Generate ¶ added in v1.6.1
func (p *SeedanceProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate creates a video using Seedance (即梦).
func (*SeedanceProvider) Name ¶ added in v1.6.1
func (p *SeedanceProvider) Name() string
func (*SeedanceProvider) SupportedFormats ¶ added in v1.6.1
func (p *SeedanceProvider) SupportedFormats() []VideoFormat
func (*SeedanceProvider) SupportsGeneration ¶ added in v1.6.1
func (p *SeedanceProvider) SupportsGeneration() bool
type SoraConfig ¶
type SoraConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
}
SoraConfig configures the OpenAI Sora video generation provider.
func DefaultSoraConfig ¶
func DefaultSoraConfig() SoraConfig
DefaultSoraConfig returns the default Sora configuration.
type SoraProvider ¶
type SoraProvider struct {
// contains filtered or unexported fields
}
SoraProvider implements video generation using OpenAI Sora 2.
func NewSoraProvider ¶
func NewSoraProvider(cfg SoraConfig, logger *zap.Logger) *SoraProvider
NewSoraProvider creates a new Sora video provider.
func (*SoraProvider) Analyze ¶
func (p *SoraProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
Analyze is not supported by the Sora provider.
func (*SoraProvider) Generate ¶
func (p *SoraProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
Generate creates a video using OpenAI Sora 2.
func (*SoraProvider) Name ¶
func (p *SoraProvider) Name() string
func (*SoraProvider) SupportedFormats ¶
func (p *SoraProvider) SupportedFormats() []VideoFormat
func (*SoraProvider) SupportsGeneration ¶
func (p *SoraProvider) SupportsGeneration() bool
type VeoConfig ¶
type VeoConfig struct {
providers.BaseProviderConfig `yaml:",inline"`
}
VeoConfig configures the Google Veo video generation provider.
func DefaultVeoConfig ¶
func DefaultVeoConfig() VeoConfig
DefaultVeoConfig returns the default Veo configuration.
type VeoProvider ¶
type VeoProvider struct {
// contains filtered or unexported fields
}
VeoProvider使用Google Veo 3.1执行视频生成. 官方端点(可被配置 BaseURL 覆盖):Base https://generativelanguage.googleapis.com POST .../models/{model}:generateVideos(同步/长轮询)→ GET .../operations/{name} 查询
func NewVeoProvider ¶
func NewVeoProvider(cfg VeoConfig, logger *zap.Logger) *VeoProvider
NewVeoProvider创建了一个新的Veo视频提供商.
func (*VeoProvider) Analyze ¶
func (p *VeoProvider) Analyze(ctx context.Context, req *AnalyzeRequest) (*AnalyzeResponse, error)
Veo不支持分析。
func (*VeoProvider) Generate ¶
func (p *VeoProvider) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error)
生成视频使用Veo 3.1.
func (*VeoProvider) Name ¶
func (p *VeoProvider) Name() string
func (*VeoProvider) SupportedFormats ¶
func (p *VeoProvider) SupportedFormats() []VideoFormat
func (*VeoProvider) SupportsGeneration ¶
func (p *VeoProvider) SupportsGeneration() bool
type VideoData ¶
type VideoData struct {
URL string `json:"url,omitempty"`
B64JSON string `json:"b64_json,omitempty"`
Duration float64 `json:"duration,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
RevisedPrompt string `json:"revised_prompt,omitempty"`
}
VideoData 表示一个已生成的视频.
type VideoFormat ¶
type VideoFormat string
VideoFormat 表示支持的视频格式.
const ( VideoFormatMP4 VideoFormat = "mp4" VideoFormatWebM VideoFormat = "webm" VideoFormatMOV VideoFormat = "mov" VideoFormatAVI VideoFormat = "avi" VideoFormatMKV VideoFormat = "mkv" )
type VideoUsage ¶
type VideoUsage struct {
VideosGenerated int `json:"videos_generated"`
DurationSeconds float64 `json:"duration_seconds"`
Cost float64 `json:"cost,omitempty"`
}
VideoUsage 表示使用统计.