Documentation
¶
Overview ¶
Package syncing provides subtitle timing synchronization for the search engine.
Index ¶
- Constants
- func ExtractEmbeddedReference(ctx context.Context, videoPath, excludeLang string, mapper subsync.LangMapper) []subsync.Cue
- func SyncAgainstReference(ctx context.Context, data []byte, videoPath, lang string, ...) subsync.SyncResult
- func SyncFromAudio(ctx context.Context, data []byte, videoPath, subtitlePath string) subsync.SyncResult
- func SyncFromCues(ctx context.Context, data []byte, refCues []subsync.Cue, videoPath string) subsync.SyncResult
- func WriteSRT(buf *bytes.Buffer, cues []subsync.Cue) error
- type SubtitleProcessor
- func (SubtitleProcessor) NormalizeEncoding(data []byte) []byte
- func (SubtitleProcessor) ParseSRT(data []byte) ([]api.SubtitleCue, error)
- func (SubtitleProcessor) ShiftCues(cues []api.SubtitleCue, offset time.Duration) []api.SubtitleCue
- func (SubtitleProcessor) SyncFromAudio(ctx context.Context, data []byte, videoPath, subtitlePath string) api.AudioSyncResult
- func (SubtitleProcessor) WriteSRT(cues []api.SubtitleCue) ([]byte, error)
- type SyncResult
- type Syncer
Constants ¶
const ( ExtASS = ".ass" ExtSSA = ".ssa" )
Subtitle format extensions used for ASS/SSA detection.
Variables ¶
This section is empty.
Functions ¶
func ExtractEmbeddedReference ¶
func ExtractEmbeddedReference(ctx context.Context, videoPath, excludeLang string, mapper subsync.LangMapper) []subsync.Cue
ExtractEmbeddedReference extracts an embedded subtitle track from the video container to use as a sync reference, excluding the target language.
func SyncAgainstReference ¶
func SyncAgainstReference(ctx context.Context, data []byte, videoPath, lang string, mapper subsync.LangMapper, minConf ...float64) subsync.SyncResult
SyncAgainstReference aligns subtitle timing against an embedded reference subtitle in the video container. Audio-based sync and external SRT sync are only available as manual actions from the web UI.
func SyncFromAudio ¶
func SyncFromAudio(ctx context.Context, data []byte, videoPath, subtitlePath string) subsync.SyncResult
SyncFromAudio runs audio-based sync on subtitle data using PCM extraction and onset correlation. Detects ASS format for native parsing, falls back to SRT otherwise.
func SyncFromCues ¶
func SyncFromCues(ctx context.Context, data []byte, refCues []subsync.Cue, videoPath string) subsync.SyncResult
SyncFromCues aligns incoming SRT data against pre-parsed reference cues.
Types ¶
type SubtitleProcessor ¶
type SubtitleProcessor struct{}
SubtitleProcessor implements api.SubtitleProcessor directly using subsync, without an intermediate backend interface.
func NewSubtitleProcessor ¶
func NewSubtitleProcessor() SubtitleProcessor
NewSubtitleProcessor creates a SubtitleProcessor.
func (SubtitleProcessor) NormalizeEncoding ¶
func (SubtitleProcessor) NormalizeEncoding(data []byte) []byte
NormalizeEncoding converts subtitle data to UTF-8.
func (SubtitleProcessor) ParseSRT ¶
func (SubtitleProcessor) ParseSRT(data []byte) ([]api.SubtitleCue, error)
ParseSRT parses SRT subtitle data into cues.
func (SubtitleProcessor) ShiftCues ¶
func (SubtitleProcessor) ShiftCues(cues []api.SubtitleCue, offset time.Duration) []api.SubtitleCue
ShiftCues applies a timing offset to all cues.
func (SubtitleProcessor) SyncFromAudio ¶
func (SubtitleProcessor) SyncFromAudio(ctx context.Context, data []byte, videoPath, subtitlePath string) api.AudioSyncResult
SyncFromAudio runs audio-based sync on subtitle data.
func (SubtitleProcessor) WriteSRT ¶
func (SubtitleProcessor) WriteSRT(cues []api.SubtitleCue) ([]byte, error)
WriteSRT serializes cues to SRT format.
type SyncResult ¶
type SyncResult = subsync.SyncResult
SyncResult is re-exported from subsync for consumer convenience.
type Syncer ¶
type Syncer struct {
// LangMapper maps ISO 639-3 codes to ISO 639-1 for ffprobe track selection.
LangMapper subsync.LangMapper
// MinConfidence is the minimum confidence threshold for auto-sync.
// When zero, defaults to api.DefaultSyncMinConfidence (0.6).
MinConfidence float64
}
Syncer implements SubtitleSyncer using the subsync library.
func (Syncer) PostProcess ¶
func (Syncer) PostProcess(data []byte, pp api.PostProcessConfig) []byte
PostProcess applies encoding normalization, HI removal, tag stripping, etc.