subtitle

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSampleSizePresent      = 0x000010
	DefaultSampleDurationPresent  = 0x000008
	SampleDescriptionIndexPresent = 0x000002
)

Variables

This section is empty.

Functions

func ProcessSubtitleSegment

func ProcessSubtitleSegment(input *bytes.Buffer, chunkId uint64, timeScale uint32, segmentDuration uint32) ([]byte, error)

ProcessSubtitleSegment processes a subtitle segment, overrides the track ID, and adds a tfdt box if missing. It takes an input buffer containing the segment data and a chunk ID. It returns an output buffer containing the processed segment data and any error encountered during processing. The function handles fragmented MP4 files and ensures that the output is properly formatted for playback. It also handles the case where the input MP4 file is not fragmented, returning an error in that case.

Note: Subtitle decryption is not supported in this implementation.

func UpdateTTMLToAbsoluteTimestamps added in v1.2.0

func UpdateTTMLToAbsoluteTimestamps(input string, segmentStartSeconds float64) (string, error)

UpdateTTMLToAbsoluteTimestamps updates relative TTML timestamps to absolute ones for smooth streaming manifests. It parses the TTML XML, adjusts the 'begin' and 'end' attributes of <p> elements by adding the segment's start time in seconds, and returns the modified TTML as a string. Returns an error if XML parsing fails.

Types

type STPPInitSegment

type STPPInitSegment struct {
	segment.BaseInitSegment
}

STPPInitSegment represents an initialization segment for STPP subtitle streams.

func (*STPPInitSegment) Generate

func (s *STPPInitSegment) Generate() (*mp4.InitSegment, error)

Generate creates an initialization segment for STPP subtitle streams. It sets the language and time scale for the segment. It returns the generated initialization segment.

If an error occurs during the generation process, it returns the error. The function also sets the language and time scale for the segment.

Note: Subtitle encryption is not supported in this implementation.

Jump to

Keyboard shortcuts

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