m3u8

package
v5.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const EndListPrefix = "#EXT-X-ENDLIST"
View Source
const HeaderPrefix = "#EXTM3U"
View Source
const ManifestSuffix = ".m3u8"
View Source
const MediaSequencePrefix = "#EXT-X-MEDIA-SEQUENCE:"
View Source
const TSInfoPrefix = "#EXTINF:"
View Source
const TSSuffix = ".ts"
View Source
const TargetDurationPrefix = "#EXT-X-TARGETDURATION:"
View Source
const VariantPrefix = "#EXT-X-STREAM-INF:"
View Source
const VersionPrefix = "#EXT-X-VERSION:"

Variables

This section is empty.

Functions

func GetLiveMediaSequence

func GetLiveMediaSequence(vod M3U8, offset time.Duration) int64

GetLiveMediaSequence gets the live media sequence, from the vod m3u8. That is, if vod has 3 TSes each 2 seconds long, and offset is 3s, this returns 2, because the 3rd second occurs within the 2nd TS (which starts at second 2 and is 2 seconds long, i.e. contains absolute seconds 2-4 of the video). The returned MediaSequence should be modded on the length of the TSes, to get the proper TSes to serve. Each time the mod is 0, the 0 TS should also insert a #EXT-X-DISCONTINUITY into the manifest, via M3U8TS.Discontinuity, in order to play correctly, assuming the TS files have correct continuity counters.

func GetTotalTime

func GetTotalTime(vod M3U8) time.Duration

GetTotalTime returns the sum of the durations of all TSes in the given vod M3U8.

func LoadTSes

func LoadTSes(m3u8 M3U8, m3u8Path string) (map[string][]byte, error)

func SerializeLive

func SerializeLive(m3u8 M3U8) []byte

SerializeLiveM3U8 serialized the given M3U8 object as a live m3u8 manifest file. It assumes the given m3u8 is valid, and does not check validity or existence of fields. Callers should check validity before calling (a M3U8 returned by TransformVodToLive without error is guaranteed valid).

Types

type M3U8

type M3U8 struct {
	Version           string
	HasVersion        bool
	TargetDuration    time.Duration
	HasTargetDuration bool
	MediaSequence     int64
	HasMediaSequence  bool
	TSes              []M3U8TS
	VARs              []M3U8VAR
}

func Parse

func Parse(fileBytes []byte) (M3U8, error)

func TransformVodToLive

func TransformVodToLive(vod M3U8, offset time.Duration, minFiles int64, minDuration time.Duration) (M3U8, error)

TransformVodToLive creates a live m3u8 from a given VOD m3u8. The created m3u8 will have TS files, of the lesser of MinLiveFiles and MinLiveDuration

type M3U8TS

type M3U8TS struct {
	Duration      time.Duration
	Discontinuity bool
	Filepath      string
}

type M3U8VAR

type M3U8VAR struct {
	Bandwidth  int
	Resolution string
	Filepath   string
}

type TagType

type TagType int
const (
	TagTypeInvalid TagType = iota
	TagTypeHeader
	TagTypeVersion
	TagTypeTargetDuration
	TagTypeMediaSequence
	TagTypeTSInfo
	TagTypeEndList
	TagTypeVariantStream
)

type TargetType

type TargetType int
const (
	TargetTypeInvalid TargetType = iota
	TargetTypeManifest
	TargetTypeTS
)

Jump to

Keyboard shortcuts

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