Documentation
¶
Overview ¶
Package syncing provides subtitle timing synchronization for the search engine.
Index ¶
- 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 InProcessExec
- type SubtitleProcessor
- type SyncExec
- type Syncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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. This is the only strategy tried here; audio-based sync enters the auto path separately via the engine's audio_sync_fallback (see Engine.syncSubtitle), and external SRT sync is manual-only 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 InProcessExec ¶ added in v0.1.148
type InProcessExec struct {
// LangMapper maps ISO 639-2/3 to 639-1 for reference-track selection.
LangMapper subsync.LangMapper
}
InProcessExec runs the strategies directly in the current process: the standalone CLI (already an isolated process), tests, and the sync-worker child itself.
func (InProcessExec) Audio ¶ added in v0.1.148
func (InProcessExec) Audio(ctx context.Context, data []byte, videoPath, subtitlePath string) subsync.SyncResult
Audio implements SyncExec in-process.
func (InProcessExec) Reference ¶ added in v0.1.148
func (e InProcessExec) Reference(ctx context.Context, data []byte, videoPath, lang string, minConf float64) subsync.SyncResult
Reference implements SyncExec in-process.
type SubtitleProcessor ¶
type SubtitleProcessor struct{}
SubtitleProcessor is the SRT text surface both handler families declare: encoding normalization, parsing and serialization. Stateless, so the zero value is the only one anyone needs.
func (SubtitleProcessor) NormalizeEncoding ¶
func (SubtitleProcessor) NormalizeEncoding(data []byte) []byte
NormalizeEncoding converts subtitle data to UTF-8.
func (SubtitleProcessor) ParseSRT ¶
func (SubtitleProcessor) ParseSRT(data []byte) ([]subflux.SubtitleCue, error)
ParseSRT parses SRT subtitle data into cues.
func (SubtitleProcessor) WriteSRT ¶
func (SubtitleProcessor) WriteSRT(cues []subflux.SubtitleCue) ([]byte, error)
WriteSRT serializes cues to SRT format.
type SyncExec ¶ added in v0.1.148
type SyncExec interface {
// Reference aligns subtitle data against an embedded reference track
// (SyncAgainstReference semantics; minConf 0 means the default threshold).
Reference(ctx context.Context, data []byte, videoPath, lang string, minConf float64) subsync.SyncResult
// Audio aligns subtitle data against the audio track (SyncFromAudio
// semantics; subtitlePath is the ASS-detection hint, may be empty).
Audio(ctx context.Context, data []byte, videoPath, subtitlePath string) subsync.SyncResult
}
SyncExec executes the two heavy sync strategies. The default implementation (InProcessExec) runs them in this process; server mode installs the syncworker client instead, which runs each job in a supervised one-shot child process so an out-of-memory sync kills the worker, not the server (P13). The seam sits BELOW every public interface: search.SubtitleSyncer, the SubtitleProcessor interfaces its handler consumers declare, and the package-level strategy functions keep their exact signatures and semantics.
type Syncer ¶
type Syncer struct {
// Exec runs the heavy alignment computation. Nil means in-process
// (LangMapper applies); server mode installs the syncworker client for
// process isolation (P13).
Exec SyncExec
// LangMapper resolves a raw ffprobe stream language tag onto subflux's
// internal code space for track selection.
LangMapper subsync.LangMapper
// MinConfidence is the minimum confidence threshold for auto-sync.
// When zero, defaults to subflux.DefaultSyncMinConfidence (0.6).
MinConfidence float64
}
Syncer implements SubtitleSyncer using the subsync library.
func (Syncer) PostProcess ¶
func (Syncer) PostProcess(data []byte, pp subflux.PostProcessConfig) []byte
PostProcess applies encoding normalization, HI removal, tag stripping, etc.