syncing

package
v0.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: GPL-2.0, GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package syncing provides subtitle timing synchronization for the search engine.

Index

Constants

View Source
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.

func WriteSRT

func WriteSRT(buf *bytes.Buffer, cues []subsync.Cue) error

WriteSRT serializes cues to SRT format. Delegates to subsync.WriteSRT.

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.

func (Syncer) Sync

func (s Syncer) Sync(ctx context.Context, data []byte, videoPath, lang string) (synced []byte, offsetMs int64)

Sync returns the (possibly modified) data and the applied offset in milliseconds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL