Bånder

HLSExporter extends MediaExporter
in package
uses EncryptsHLSSegments

Table of Contents

Constants

ENCRYPTION_LISTENER  = "listen-encryption-key"
HLS_KEY_INFO_FILENAME  = 'hls_encryption.keyinfo'

Properties

$concatWithAudio  : bool
$concatWithTranscoding  : bool
$concatWithVideo  : bool
$driver  : PHPFFMpeg
$lastPercentage  : float
$lastRemaining  : float
$maps  : Collection
$mustBeAccurate  : bool
$onProgressCallback  : Closure
$returnFrameContents  : bool
$timelapseFramerate  : float
$visibility  : string
$encryptionIV  : string
Encryption IV
$encryptionKey  : string
The encryption key.
$encryptionKeyFilename  : string
The encryption key filename.
$encryptionSecretsRoot  : mixed
Disk to store the secrets.
$keyFrameInterval  : int
$listener  : StdListener
Listener that will rotate the key.
$nextEncryptionFilenameAndKey  : array<string|int, mixed>
A fresh filename and encryption key for the next round.
$onNewEncryptionKey  : callable
Gets called whenever a new encryption key is set.
$pendingFormats  : Collection
$playlistGenerator  : PlaylistGenerator
$rotateEncryptiongKey  : bool
Wether to rotate the key on every segment.
$segmentFilenameGenerator  : Closure
$segmentLength  : int
$segmentsOpened  : int
Number of opened segments.
$segmentsPerKey  : int
Number of segments that can use the same key.

Methods

__call()  : mixed
Forwards the call to the driver object and returns the result if it's something different than the driver object itself.
__construct()  : mixed
accurate()  : self
addFormat()  : self
Initializes the $pendingFormats property when needed and adds the format with the optional callback to add filters.
addFormatOutputMapping()  : mixed
addTileFilter()  : self
Calls the callable with a TileFactory instance and adds the freshly generated TileFilter.
afterSaving()  : self
Adds a callable to the callbacks array.
asTimelapseWithFramerate()  : self
concatWithTranscoding()  : self
dd()  : void
Dump the final command and end the script.
generateEncryptionKey()  : string
Creates a new encryption key.
generateEncryptionKeyFilename()  : string
Creates a new encryption key filename.
generateTemporarySegmentPlaylistFilename()  : string
Returns the filename of a segment playlist by its key. We let FFmpeg generate a playlist for each added format so we don't have to detect the bitrate and codec ourselves.
getAccuracy()  : bool
getCommand()  : mixed
Prepares the saves command but returns the command instead.
getFrameContents()  : string
getProcessOutput()  : ProcessOutput
inFormat()  : self
onProgress()  : HasProgressListener|MediaExporter
Setter for the callback.
save()  : MediaOpener
Runs the export, generates the main playlist, and cleans up the segment playlist guides and temporary HLS encryption keys.
setKeyFrameInterval()  : self
Setter for the Key Frame interval
setSegmentLength()  : self
Setter for the segment length
toDisk()  : mixed
unaccurate()  : self
useSegmentFilenameGenerator()  : self
Setter for a callback that generates a segment filename.
withEncryptionKey()  : HLSExporter|EncryptsHLSSegments
Initialises the disk, info and IV for encryption and sets the key.
withPlaylistGenerator()  : self
Method to set a different playlist generator than the default HLSPlaylistGenerator.
withRotatingEncryptionKey()  : HLSExporter|EncryptsHLSSegments
Enables encryption with rotating keys. The callable will receive every new key and the integer sets the number of segments that can use the same key.
withVisibility()  : mixed
addTimelapseParametersToFormat()  : mixed
getDisk()  : Disk
getMediaOpener()  : MediaOpener
runAfterSavingCallbacks()  : mixed
addConcatFilterAndMapping()  : mixed
addHandlerToRotateEncryptionKey()  : void
Adds a listener and handler to rotate the key on every new HLS segment.
addHLSParametersToFormat()  : array<string|int, mixed>
Merges the HLS parameters to the given format.
applyFiltersCallback()  : array<string|int, mixed>
Gives the callback an HLSVideoFilters object that provides addFilter(), addLegacyFilter(), addWatermark() and resize() helper methods. It returns a mapping for the video and (optional) audio stream.
applyProgressListenerToFormat()  : void
Only calls the callback if the percentage is below 100 and is different from the previous emitted percentage.
cleanupHLSEncryption()  : HLSExporter|EncryptsHLSSegments
Removes the encryption keys from the temporary disk.
cleanupSegmentPlaylistGuides()  : self
Loops through each added format and then deletes the temporary segment playlist, which we generate manually using the HLSPlaylistGenerator.
getEncrypedHLSParameters()  : array<string|int, mixed>
Returns an array with the encryption parameters.
getPlaylistGenerator()  : PlaylistGenerator
getSegmentFilenameGenerator()  : callable
Returns a default generator if none is set.
getSegmentPatternAndFormatPlaylistPath()  : array<string|int, mixed>
Calls the generator with the path (without extension), format and key.
prepareSaving()  : Collection
Adds a mapping for each added format and automatically handles the mapping for filters. Adds a handler to rotate the encryption key (optional).
removeHandlerThatRotatesEncryptionKey()  : HLSExporter|EncryptsHLSSegments
Remove the listener at the end of the export to prevent duplicate event handlers.
replaceAbsolutePathsHLSEncryption()  : HLSExporter|EncryptsHLSSegments
While encoding, the encryption keys are saved to a temporary directory.
rotateEncryptionKey()  : string
Rotates the key and returns the absolute path to the info file. This method should be executed as fast as possible, or we might be too late for FFmpeg opening the next segment. That's why we don't use the Disk-class magic.

Constants

ENCRYPTION_LISTENER

public mixed ENCRYPTION_LISTENER = "listen-encryption-key"

HLS_KEY_INFO_FILENAME

public mixed HLS_KEY_INFO_FILENAME = 'hls_encryption.keyinfo'

Properties

$returnFrameContents

protected bool $returnFrameContents = false

$encryptionKeyFilename

The encryption key filename.

private string $encryptionKeyFilename

$encryptionSecretsRoot

Disk to store the secrets.

private mixed $encryptionSecretsRoot

$keyFrameInterval

private int $keyFrameInterval = 48

$nextEncryptionFilenameAndKey

A fresh filename and encryption key for the next round.

private array<string|int, mixed> $nextEncryptionFilenameAndKey

$onNewEncryptionKey

Gets called whenever a new encryption key is set.

private callable $onNewEncryptionKey

$rotateEncryptiongKey

Wether to rotate the key on every segment.

private bool $rotateEncryptiongKey = false

$segmentFilenameGenerator

private Closure $segmentFilenameGenerator = null

$segmentsPerKey

Number of segments that can use the same key.

private int $segmentsPerKey = 1

Methods

__call()

Forwards the call to the driver object and returns the result if it's something different than the driver object itself.

public __call(mixed $method, mixed $arguments) : mixed
Parameters
$method : mixed
$arguments : mixed

addFormat()

Initializes the $pendingFormats property when needed and adds the format with the optional callback to add filters.

public addFormat(FormatInterface $format[, callable $filtersCallback = null ]) : self
Parameters
$format : FormatInterface
$filtersCallback : callable = null
Return values
self

addFormatOutputMapping()

public addFormatOutputMapping(FormatInterface $format, Media $output, array<string|int, mixed> $outs[, mixed $forceDisableAudio = false ][, mixed $forceDisableVideo = false ]) : mixed
Parameters
$format : FormatInterface
$output : Media
$outs : array<string|int, mixed>
$forceDisableAudio : mixed = false
$forceDisableVideo : mixed = false

addTileFilter()

Calls the callable with a TileFactory instance and adds the freshly generated TileFilter.

public addTileFilter(callable $withTileFactory) : self
Parameters
$withTileFactory : callable
Return values
self

afterSaving()

Adds a callable to the callbacks array.

public afterSaving(callable $callback) : self
Parameters
$callback : callable
Return values
self

asTimelapseWithFramerate()

public asTimelapseWithFramerate(float $framerate) : self
Parameters
$framerate : float
Return values
self

concatWithTranscoding()

public concatWithTranscoding([bool $hasVideo = true ][, bool $hasAudio = true ]) : self
Parameters
$hasVideo : bool = true
$hasAudio : bool = true
Return values
self

dd()

Dump the final command and end the script.

public dd([string $path = null ]) : void
Parameters
$path : string = null

generateEncryptionKey()

Creates a new encryption key.

public static generateEncryptionKey() : string
Return values
string

generateEncryptionKeyFilename()

Creates a new encryption key filename.

public static generateEncryptionKeyFilename() : string
Return values
string

generateTemporarySegmentPlaylistFilename()

Returns the filename of a segment playlist by its key. We let FFmpeg generate a playlist for each added format so we don't have to detect the bitrate and codec ourselves.

public static generateTemporarySegmentPlaylistFilename(int $key) : string

We use this as a reference so when can generate our own main playlist.

Parameters
$key : int
Return values
string

getAccuracy()

public getAccuracy() : bool
Return values
bool

getCommand()

Prepares the saves command but returns the command instead.

public getCommand([string $path = null ]) : mixed
Parameters
$path : string = null

getFrameContents()

public getFrameContents() : string
Return values
string

inFormat()

public inFormat(FormatInterface $format) : self
Parameters
$format : FormatInterface
Return values
self

save()

Runs the export, generates the main playlist, and cleans up the segment playlist guides and temporary HLS encryption keys.

public save([string $mainPlaylistPath = null ]) : MediaOpener
Parameters
$mainPlaylistPath : string = null
Return values
MediaOpener

setKeyFrameInterval()

Setter for the Key Frame interval

public setKeyFrameInterval(int $interval) : self
Parameters
$interval : int
Return values
self

setSegmentLength()

Setter for the segment length

public setSegmentLength(int $length) : self
Parameters
$length : int
Return values
self

toDisk()

public toDisk(mixed $disk) : mixed
Parameters
$disk : mixed

useSegmentFilenameGenerator()

Setter for a callback that generates a segment filename.

public useSegmentFilenameGenerator(Closure $callback) : self
Parameters
$callback : Closure
Return values
self

withPlaylistGenerator()

Method to set a different playlist generator than the default HLSPlaylistGenerator.

public withPlaylistGenerator(PlaylistGenerator $playlistGenerator) : self
Parameters
$playlistGenerator : PlaylistGenerator
Return values
self

withRotatingEncryptionKey()

Enables encryption with rotating keys. The callable will receive every new key and the integer sets the number of segments that can use the same key.

public withRotatingEncryptionKey(Closure $callback[, int $segmentsPerKey = 1 ]) : HLSExporter|EncryptsHLSSegments
Parameters
$callback : Closure
$segmentsPerKey : int = 1
Return values
HLSExporter|EncryptsHLSSegments

withVisibility()

public withVisibility(string $visibility) : mixed
Parameters
$visibility : string

addTimelapseParametersToFormat()

protected addTimelapseParametersToFormat() : mixed

runAfterSavingCallbacks()

protected runAfterSavingCallbacks([Media $outputMedia = null ]) : mixed
Parameters
$outputMedia : Media = null

addHandlerToRotateEncryptionKey()

Adds a listener and handler to rotate the key on every new HLS segment.

private addHandlerToRotateEncryptionKey() : void

addHLSParametersToFormat()

Merges the HLS parameters to the given format.

private addHLSParametersToFormat(DefaultAudio $format, string $segmentsPattern, Disk $disk, int $key) : array<string|int, mixed>
Parameters
$format : DefaultAudio
$segmentsPattern : string
$disk : Disk
$key : int
Return values
array<string|int, mixed>

applyFiltersCallback()

Gives the callback an HLSVideoFilters object that provides addFilter(), addLegacyFilter(), addWatermark() and resize() helper methods. It returns a mapping for the video and (optional) audio stream.

private applyFiltersCallback(callable $filtersCallback, int $formatKey) : array<string|int, mixed>
Parameters
$filtersCallback : callable
$formatKey : int
Return values
array<string|int, mixed>

applyProgressListenerToFormat()

Only calls the callback if the percentage is below 100 and is different from the previous emitted percentage.

private applyProgressListenerToFormat(EventEmitterInterface $format) : void
Parameters
$format : EventEmitterInterface

cleanupSegmentPlaylistGuides()

Loops through each added format and then deletes the temporary segment playlist, which we generate manually using the HLSPlaylistGenerator.

private cleanupSegmentPlaylistGuides(Media $media) : self
Parameters
$media : Media
Return values
self

getEncrypedHLSParameters()

Returns an array with the encryption parameters.

private getEncrypedHLSParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSegmentFilenameGenerator()

Returns a default generator if none is set.

private getSegmentFilenameGenerator() : callable
Return values
callable

getSegmentPatternAndFormatPlaylistPath()

Calls the generator with the path (without extension), format and key.

private getSegmentPatternAndFormatPlaylistPath(string $baseName, AudioInterface $format, int $key) : array<string|int, mixed>
Parameters
$baseName : string
$format : AudioInterface
$key : int
Return values
array<string|int, mixed>

prepareSaving()

Adds a mapping for each added format and automatically handles the mapping for filters. Adds a handler to rotate the encryption key (optional).

private prepareSaving([string $path = null ]) : Collection

Returns a media collection of all segment playlists.

Parameters
$path : string = null
Tags
throws
NoFormatException
Return values
Collection

replaceAbsolutePathsHLSEncryption()

While encoding, the encryption keys are saved to a temporary directory.

private replaceAbsolutePathsHLSEncryption(Collection $playlistMedia) : HLSExporter|EncryptsHLSSegments

With this method, we loop through all segment playlists and replace the absolute path to the keys to a relative ones.

Parameters
$playlistMedia : Collection
Return values
HLSExporter|EncryptsHLSSegments

rotateEncryptionKey()

Rotates the key and returns the absolute path to the info file. This method should be executed as fast as possible, or we might be too late for FFmpeg opening the next segment. That's why we don't use the Disk-class magic.

private rotateEncryptionKey() : string
Return values
string

        
On this page

Search results