Documentation
¶
Index ¶
- func AddAudioToVideo(ctx context.Context, videoPath, audioPath, outputPath string) error
- func BCP47ToISO639(bcp47 string) string
- func BurnSubtitles(videoPath, subtitlePath, outputPath string) error
- func CheckFFmpeg() error
- func DetectLanguageFromSubtitlePath(path string) string
- func EmbedSubtitles(videoPath, subtitlePath, language, outputPath string) error
- func GetEncoderDescription(config EncoderConfig) string
- func GetVideoCodec(config EncoderConfig) (codec string, args []string)
- func GetVideoDuration(videoPath string) (float64, error)
- func ReplaceAudio(ctx context.Context, videoPath, audioPath, outputPath string) error
- func SetGlobalEncoderConfig(config EncoderConfig)
- type BrowserVideoProvider
- func (p *BrowserVideoProvider) CreateVideo(ctx context.Context, seg segment.Segment, audioPath string, outputPath string) (int, error)
- func (p *BrowserVideoProvider) CreateVideoWithTiming(ctx context.Context, seg segment.Segment, stepDurations map[int]int, ...) (int, error)
- func (p *BrowserVideoProvider) SupportsSegmentType(sourceType segment.SourceType) bool
- type Combiner
- type EncoderConfig
- type EncoderType
- type ImageVideoConfig
- type ImageVideoConverter
- type ImageVideoProvider
- func (p *ImageVideoProvider) CreateVideo(ctx context.Context, seg segment.Segment, audioPath string, outputPath string) (int, error)
- func (p *ImageVideoProvider) CreateVideoWithDuration(ctx context.Context, seg segment.Segment, audioPath string, outputPath string, ...) (int, error)
- func (p *ImageVideoProvider) SupportsSegmentType(sourceType segment.SourceType) bool
- type ProviderRegistry
- type Recorder
- type RecorderConfig
- type UnsupportedSegmentError
- type VideoProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAudioToVideo ¶
AddAudioToVideo combines a video (possibly silent) with an audio track.
func BCP47ToISO639 ¶
BCP47ToISO639 converts a BCP-47 language code to ISO 639-2 (3-letter) code. If the code is not found, it returns the first 3 characters or the original code.
func BurnSubtitles ¶
BurnSubtitles burns subtitles directly into the video frames. The subtitles become permanent and cannot be toggled off. This is useful for social media or when subtitle track support is limited.
func DetectLanguageFromSubtitlePath ¶
DetectLanguageFromSubtitlePath extracts the language code from a subtitle filename. Supports patterns like "en-US.srt", "subtitles/fr-FR.vtt", "slide_001.en-US.srt"
func EmbedSubtitles ¶
EmbedSubtitles embeds a subtitle file into a video as a soft subtitle track. The subtitle track can be toggled on/off by the viewer. Supports SRT and VTT formats.
func GetEncoderDescription ¶
func GetEncoderDescription(config EncoderConfig) string
GetEncoderDescription returns a human-readable description of the encoder being used.
func GetVideoCodec ¶
func GetVideoCodec(config EncoderConfig) (codec string, args []string)
GetVideoCodec returns the FFmpeg video codec arguments based on the encoder config. Returns the codec name and any additional arguments.
func GetVideoDuration ¶
GetVideoDuration gets the duration of a video file using ffprobe
func ReplaceAudio ¶
ReplaceAudio replaces the audio track in a video file.
func SetGlobalEncoderConfig ¶
func SetGlobalEncoderConfig(config EncoderConfig)
SetGlobalEncoderConfig sets the global encoder configuration.
Types ¶
type BrowserVideoProvider ¶
type BrowserVideoProvider struct {
// contains filtered or unexported fields
}
BrowserVideoProvider creates videos by recording browser sessions.
func NewBrowserVideoProvider ¶
func NewBrowserVideoProvider(width, height, frameRate int, headless bool, workDir string) *BrowserVideoProvider
NewBrowserVideoProvider creates a new browser video provider.
func (*BrowserVideoProvider) CreateVideo ¶
func (p *BrowserVideoProvider) CreateVideo(ctx context.Context, seg segment.Segment, audioPath string, outputPath string) (int, error)
CreateVideo records a browser session and combines it with audio.
func (*BrowserVideoProvider) CreateVideoWithTiming ¶
func (p *BrowserVideoProvider) CreateVideoWithTiming(ctx context.Context, seg segment.Segment, stepDurations map[int]int, outputPath string) (int, error)
CreateVideoWithTiming records a browser session using timing from TTS durations. This ensures steps are paced to match voiceover length.
func (*BrowserVideoProvider) SupportsSegmentType ¶
func (p *BrowserVideoProvider) SupportsSegmentType(sourceType segment.SourceType) bool
SupportsSegmentType returns true for browser segments.
type Combiner ¶
type Combiner struct {
// contains filtered or unexported fields
}
Combiner handles concatenation of video segments
func NewCombiner ¶
NewCombiner creates a new video combiner
func (*Combiner) CombineVideos ¶
CombineVideos concatenates multiple video files into one Uses filter_complex concat to properly handle mixed audio formats (different sample rates)
type EncoderConfig ¶
type EncoderConfig struct {
// Type specifies which encoder to use
Type EncoderType
// Preset for encoding speed/quality tradeoff (for libx264: ultrafast, fast, medium, slow)
Preset string
// CRF (Constant Rate Factor) for quality (lower = better, 18-28 typical)
CRF int
}
EncoderConfig holds configuration for video encoding.
func DefaultEncoderConfig ¶
func DefaultEncoderConfig() EncoderConfig
DefaultEncoderConfig returns a default encoder configuration.
func FastEncoderConfig ¶
func FastEncoderConfig() EncoderConfig
FastEncoderConfig returns a configuration optimized for speed using hardware encoding.
func GetGlobalEncoderConfig ¶
func GetGlobalEncoderConfig() EncoderConfig
GetGlobalEncoderConfig returns the current global encoder configuration.
type EncoderType ¶
type EncoderType string
EncoderType represents the type of video encoder to use.
const ( // EncoderSoftware uses libx264 (CPU-based, universal compatibility) EncoderSoftware EncoderType = "software" // EncoderHardware uses hardware acceleration when available EncoderHardware EncoderType = "hardware" // EncoderAuto automatically selects the best available encoder EncoderAuto EncoderType = "auto" )
type ImageVideoConfig ¶
ImageVideoConfig holds configuration for image-to-video conversion
type ImageVideoConverter ¶
type ImageVideoConverter struct {
// contains filtered or unexported fields
}
ImageVideoConverter creates videos from static images with audio
func NewImageVideoConverter ¶
func NewImageVideoConverter(config ImageVideoConfig) *ImageVideoConverter
NewImageVideoConverter creates a new image video converter
func (*ImageVideoConverter) CreateSlideVideo ¶
func (c *ImageVideoConverter) CreateSlideVideo(ctx context.Context, slideIndex int, imagePath, audioPath string, duration time.Duration) (string, error)
CreateSlideVideo creates a video from a static image and audio file
func (*ImageVideoConverter) CreateSlideVideoWithSize ¶
func (c *ImageVideoConverter) CreateSlideVideoWithSize(ctx context.Context, slideIndex int, imagePath, audioPath string, duration time.Duration, width, height int) (string, error)
CreateSlideVideoWithSize creates a video with specific dimensions
type ImageVideoProvider ¶
type ImageVideoProvider struct {
// contains filtered or unexported fields
}
ImageVideoProvider creates videos from static images (for slide segments).
func NewImageVideoProvider ¶
func NewImageVideoProvider(width, height, frameRate int) *ImageVideoProvider
NewImageVideoProvider creates a new image video provider.
func (*ImageVideoProvider) CreateVideo ¶
func (p *ImageVideoProvider) CreateVideo(ctx context.Context, seg segment.Segment, audioPath string, outputPath string) (int, error)
CreateVideo generates a video from a slide's image and audio.
func (*ImageVideoProvider) CreateVideoWithDuration ¶
func (p *ImageVideoProvider) CreateVideoWithDuration(ctx context.Context, seg segment.Segment, audioPath string, outputPath string, durationMs int) (int, error)
CreateVideoWithDuration generates a video with a specific duration (padding audio if needed).
func (*ImageVideoProvider) SupportsSegmentType ¶
func (p *ImageVideoProvider) SupportsSegmentType(sourceType segment.SourceType) bool
SupportsSegmentType returns true for slide segments.
type ProviderRegistry ¶
type ProviderRegistry struct {
// contains filtered or unexported fields
}
ProviderRegistry manages multiple video providers and routes segments to the appropriate one.
func NewProviderRegistry ¶
func NewProviderRegistry() *ProviderRegistry
NewProviderRegistry creates a new provider registry.
func (*ProviderRegistry) CreateVideo ¶
func (r *ProviderRegistry) CreateVideo(ctx context.Context, seg segment.Segment, audioPath string, outputPath string) (int, error)
CreateVideo routes to the appropriate provider based on segment type.
func (*ProviderRegistry) GetProvider ¶
func (r *ProviderRegistry) GetProvider(sourceType segment.SourceType) VideoProvider
GetProvider returns a provider that can handle the given segment type.
func (*ProviderRegistry) Register ¶
func (r *ProviderRegistry) Register(p VideoProvider)
Register adds a provider to the registry.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder handles screen recording with audio
func NewRecorder ¶
func NewRecorder(config RecorderConfig) *Recorder
NewRecorder creates a new video recorder
type RecorderConfig ¶
type RecorderConfig struct {
OutputDir string
Width int
Height int
FrameRate int
AudioInput string // Path to audio file to play during recording
ScreenDevice string // Screen capture device (macOS: auto-detected if empty)
}
RecorderConfig holds video recording configuration
type UnsupportedSegmentError ¶
type UnsupportedSegmentError struct {
SourceType segment.SourceType
}
UnsupportedSegmentError is returned when no provider supports a segment type.
func (*UnsupportedSegmentError) Error ¶
func (e *UnsupportedSegmentError) Error() string
type VideoProvider ¶
type VideoProvider interface {
// CreateVideo generates a video for a segment.
// audioPath is the path to the audio file to combine with the video.
// outputPath is where the video should be written.
// Returns the actual duration of the generated video in milliseconds.
CreateVideo(ctx context.Context, seg segment.Segment, audioPath string, outputPath string) (int, error)
// SupportsSegmentType returns true if this provider can handle the given segment type.
SupportsSegmentType(sourceType segment.SourceType) bool
}
VideoProvider creates videos from segments. Different implementations handle different segment types.