Forge
1.x
Docs/Forge/Functions
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/extensions/hls/functions.mdx

Extension Entry Points01

FunctionDescription
NewExtension(opts ...ConfigOption) forge.ExtensionCreate the HLS extension with functional options
NewExtensionWithConfig(config Config) forge.ExtensionCreate the HLS extension with a complete config
DefaultConfig() ConfigReturns the default configuration

HLS Interface -- Stream Management02

MethodDescription
CreateStream(ctx, options) (*Stream, error)Create a new stream (live, VOD, or event)
GetStream(ctx, streamID) (*Stream, error)Get stream information
DeleteStream(ctx, streamID) errorDelete a stream and its segments
ListStreams(ctx) ([]*Stream, error)List all streams
StartStream(ctx, streamID) errorStart a live stream
StopStream(ctx, streamID) errorStop a live stream

HLS Interface -- Segment Operations03

MethodDescription
IngestSegment(ctx, streamID, variantID, data) errorPush a media segment
GetSegment(ctx, streamID, variantID, segmentNum) (io.ReadCloser, error)Retrieve a segment

HLS Interface -- Playlists04

MethodDescription
GetMasterPlaylist(ctx, streamID) (string, error)Generate the master playlist (m3u8)
GetMediaPlaylist(ctx, streamID, variantID) (string, error)Generate a media playlist

HLS Interface -- Stats05

MethodDescription
GetStreamStats(ctx, streamID) (*StreamStats, error)Get stream statistics

Playlist Generator06

FunctionDescription
NewPlaylistGenerator(baseURL) *PlaylistGeneratorCreate a playlist generator
GenerateMasterPlaylist(stream) stringGenerate a master m3u8 playlist
GenerateMediaPlaylist(stream, variantID) stringGenerate a media m3u8 playlist

Utility Functions07

FunctionDescription
DefaultProfiles() []TranscodeProfileGet default transcode profiles (360p to 4K)
FormatResolution(width, height) stringFormat a resolution string
ParseResolution(resolution) (width, height, error)Parse a resolution string
GenerateCodecsString(profile) stringGenerate HLS codecs attribute string

Key Types08

StreamOptions

FieldTypePurpose
NamestringStream display name
TypeStreamTypelive, vod, or event
Profiles[]TranscodeProfileQuality profiles to generate

TranscodeProfile

FieldTypePurpose
NamestringProfile name (e.g. "720p")
WidthintOutput width
HeightintOutput height
VideoBitrateintVideo bitrate (kbps)
AudioBitrateintAudio bitrate (kbps)
VideoCodecstringVideo codec (e.g. "h264")
AudioCodecstringAudio codec (e.g. "aac")