PHPackages                             aminyazdanpanah/php-shaka - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. aminyazdanpanah/php-shaka

ActiveLibrary[Image &amp; Media](/categories/media)

aminyazdanpanah/php-shaka
=========================

Shaka PHP is a library that uses Shaka Packager for DASH and HLS packaging and encryption, supporting Common Encryption for Widevine and other DRM Systems.

v1.0.5(2w ago)939.6k↑63.3%28[2 issues](https://github.com/quasarstream/shaka-php/issues)1MITPHPPHP &gt;=7.2CI failing

Since Mar 11Pushed 2w ago5 watchersCompare

[ Source](https://github.com/quasarstream/shaka-php)[ Packagist](https://packagist.org/packages/aminyazdanpanah/php-shaka)[ RSS](/packages/aminyazdanpanah-php-shaka/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (4)Versions (8)Used By (1)

Shaka PHP
=========

[](#shaka-php)

[![Build Status](https://camo.githubusercontent.com/04984673435e28f8c163f010d6fafc49d21a936567c7a0dd562c9a2a45cec081/68747470733a2f2f7472617669732d63692e6f72672f616d696e79617a64616e70616e61682f7368616b612d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aminyazdanpanah/shaka-php)[![Build status](https://camo.githubusercontent.com/3b04eb0a560bbc417196ebe130f54d6825294df44805d5ab445a90da8885a38c/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f616d696e79617a64616e70616e61682f7368616b612d7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265266c6f676f3d6170707665796f72)](https://ci.appveyor.com/project/aminyazdanpanah/shaka-php)

Shaka PHP is a library that uses **[Shaka Packager](https://github.com/google/shaka-packager)** for DASH and HLS packaging and encryption, supporting Common Encryption for Widevine and other DRM Systems.

**Contents**

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    - [Basic Usage](#basic-usage)
    - [DASH](#dash)
    - [HLS](#hls)
    - [Live](#live)
    - [DRM](#drm)
        - [Widevine Key Server](#widevine-key-server)
        - [PlayReady Key Server](#playready-key-server)
        - [Raw Key](#raw-key-server)
    - [Ad Insertion](#ad-insertion)
- [Several Open Source Players](#several-open-source-players)
- [Contributing and Reporting Bugs](#contributing-and-reporting-bugs)
- [Credits](#credits)
- [License](#license)

Requirements
------------

[](#requirements)

1. This version of the package is only compatible with PHP 7.2 or higher.
2. This library requires a working Shaka Packager binary. Be that the binary can be located with system PATH to auto get binary file in PHP. You can also give the binary path on load.

### Getting Shaka Packager

[](#getting-shaka-packager)

There are several ways you can get Shaka Packager.

- Using **[Docker](https://www.docker.com/whatisdocker)**. Instructions are available at **[Using Docker](https://google.github.io/shaka-packager/html/docker_instructions.html)**.
- Get prebuilt binaries from **[release](https://github.com/google/shaka-packager/releases)**.
- Built from source, see **[Build Instructions](https://google.github.io/shaka-packager/html/build_instructions.html)** for details.

For users who get prebuilt binary: Please rename `packager-'OS'` to `packager` and add the path of shaka packager to your system PATH.(e.g. 'packager-win.exe' to 'packager.exe')

Installation
------------

[](#installation)

Use **[Composer](https://getcomposer.org)** to install this library from Packagist:

Run the following command from your project directory to add the dependency:

```
composer require aminyazdanpanah/php-shaka
```

Alternatively, add the dependency directly to your `composer.json` file:

```
"require": {
    "aminyazdanpanah/php-shaka": "^1.0"
}
```

Usage
-----

[](#usage)

The best way to learn how to use this library is to review the **[examples](/examples)** and browse the source code as it is self-documented.

It is **highly recommended** to read **[Shaka Packager Documentation](https://google.github.io/shaka-packager/html/index.html)**.

### Basic Usage

[](#basic-usage)

#### Initializing

[](#initializing)

Shaka PHP auto-detect `packager` binary. An associative array of config can also be passed to the `initialize` method to give binary path and timout explicitly:

```
$config = [
    'packager.binaries' => 'path/to/packager/binary',
    'timeout'           =>  3600
];

$shaka = \Shaka\Shaka::initialize($config);
```

#### Streams

[](#streams)

There can be multiple `streams` with input from the same “file” or multiple different “files”.

```
$stream1 = \Shaka\Options\Streams\Stream::input('/the/path/to/the/file');
$stream2 = \Shaka\Options\Streams\Stream::input('/the/path/to/the/file');
//...
```

you can add options to your streams

```
$stream1->streamSelector('video')
        ->output('video.mp4');
```

##### Stream Options

[](#stream-options)

OptionDefaultDescriptionstreamSelector()NULLRequired field with value ‘audio’, ‘video’, ‘text’ or stream number (zero based).output()NULLRequired output file path (single file).initSegment()NULLinitialization segment path (multiple file).segmentTemplate()NULLOptional value which specifies the naming pattern for the segment files, and that the stream should be split into multiple files. Its presence should be consistent across streams.bandwidth()NULLOptional value which contains a user-specified maximum bit rate for the stream, in bits/sec. If specified, this value is propagated to (HLS) EXT-X-STREAM-INF:BANDWIDTH or (DASH) Representation@bandwidth and the $Bandwidth$ template parameter for segment names. If not specified, the bandwidth value is estimated from content bitrate. Note that it only affects the generated manifests/playlists; it has no effect on the media content itself.language()NULLOptional value which contains a user-specified language tag. If specified, this value overrides any language metadata in the input stream.outputFormat()NULLOptional value which specifies the format of the output files (MP4 or WebM). If not specified, it will be derived from the file extension of the output file.trickPlayFactor()0Optional value which specifies the trick play, a.k.a. trick mode, stream sampling rate among key frames. If specified, the output is a trick play stream.#### Media File Analysis

[](#media-file-analysis)

It can be used to inspect the content of a media file and dump basic stream information:

```
$export = $shaka->streams($stream)
    ->mediaFileAnalysis()
    ->export();
```

The `$export` is instance of `StreamCollection`. For more information, please see **[examples](/examples)**.

#### Basic Transmuxing

[](#basic-transmuxing)

It can be used to extract streams, optionally transmuxes the streams from one container format to another container format.

```
$stream1 = Stream::input('/the/path/to/the/file')
    ->streamSelector('video')
    ->output('video.mp4');

$stream2 = Stream::input('/the/path/to/the/file')
    ->streamSelector('audio')
    ->output('audio.mp4');

$export = $shaka->streams($stream1, $stream2)
            ->mediaPackaging()
            ->export();
```

#### Basic Usage Examples

[](#basic-usage-examples)

Please see **[examples/Basic](/examples/basic)** for details.

### DASH

[](#dash)

**[Dynamic Adaptive Streaming over HTTP](http://dashif.org/)** (DASH) is an adaptive bitrate streaming technique that enables high quality streaming of media content over HTTP.

#### DASH Stream Options

[](#dash-stream-options)

Besides **[Stream Options](#stream-options)** and **[DRM Stream Options](#drm-stream-options)**, you can add `DASHRoles()` method to your DASHStream object. You can pass roles to the method. The roles can be separated by colon or semi-colon. The value should be one of: caption, subtitle, main, alternate, supplementary, commentary and dub. See **[DASH (ISO/IEC 23009-1)](https://www.iso.org/standard/65274.html)** specification for details.

```
$stream1 = $stream1 = DASHStream::input('/the/path/to/the/file')
                        //->other options
```

#### DASH Packaging

[](#dash-packaging)

This library supports DASH content packaging.

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->DASH('output.mpd')
    ->export();
```

You can add options to your DASH object using a callback method:

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->DASH('output.mpd', function ($options) {
        return $options->generateStaticLiveMpd();
            //->other options;
    })
    ->export();
```

#### DASH Options

[](#dash-options)

OptionDefaultDescriptiongenerateStaticLiveMpd()FALSEIf enabled, generates static mpd. If segment\_template is specified in stream descriptors, shaka-packager generates dynamic mpd by default; if this flag is enabled, shaka-packager generates static mpd instead. Note that if segment\_template is not specified, shaka-packager always generates static mpd regardless of the value of this flag.baseUrls()NULLComma separated BaseURLs for the MPD: \[,\]…. The values will be added as element(s) immediately under the element.minBufferTime()NULLSpecifies, in seconds, a common duration used in the definition of the MPD Representation data rate.minimumUpdatePeriod()NULLIndicates to the player how often to refresh the media presentation description in seconds. This value is used for dynamic MPD only.suggestedPresentationDelay()NULLSpecifies a delay, in seconds, to be added to the media presentation time. This value is used for dynamic MPD only.timeShiftBufferDepth()NULLGuaranteed duration of the time shifting buffer for dynamic media presentations, in seconds.preservedSegmentsOutsideLiveWindow()NULLSegments outside the live window (defined by time\_shift\_buffer\_depth above) are automatically removed except for the most recent X segments defined by this parameter. This is needed to accommodate latencies in various stages of content serving pipeline, so that the segments stay accessible as they may still be accessed by the player. The segments are not removed if the value is zero.utcTimings()NULLComma separated UTCTiming schemeIdUri and value pairs for the MPD: &lt;scheme\_id\_uri&gt;=\[,&lt;scheme\_id\_uri&gt;=\]… This value is used for dynamic MPD only.defaultLanguage()NULLAny audio/text tracks tagged with this language will have &lt;Role … value=”main” /&gt; in the manifest. This allows the player to choose the correct default language for the content. This applies to both audio and text tracks. The default language for text tracks can be overriden by ‘default\_text\_language’.defaultTextLanguage()NULLSame as above, but this applies to text tracks only, and overrides the default language for text tracks.allowApproximateSegmentTimeline()NULLFor live profile only. If enabled, segments with close duration (i.e. with difference less than one sample) are considered to have the same duration. This enables MPD generator to generate less SegmentTimeline entries. If all segments are of the same duration except the last one, we will do further optimization to use SegmentTemplate@duration instead and omit SegmentTimeline completely. Ignored if $Time$ is used in segment template, since $Time$ requires accurate Segment Timeline.Also you can add some `Chunking` and `MP4 output` options to your DASH Object(before using these options, please read the `Description`):

#### Chunking and MP4 Output Options

[](#chunking-and-mp4-output-options)

OptionDefaultDescriptionMp4IncludePsshInStream()TRUEMP4 only: include pssh in the encrypted stream.generateSidxInMediaSegments()NULLFor MP4 with DASH live profile only: Indicates whether to generate ‘sidx’ box in media segments. Note that it is reuqired by spec if segment template contains $Time$ specifier.nogenerateSidxInMediaSegments()NULLFor MP4 with DASH live profile only: Indicates whether to generate ‘sidx’ box in media segments. Note that it is reuqired by spec if segment template contains $Time$ specifier.transportStreamTimestampOffsetMs()100msTransport stream only (MPEG2-TS, HLS Packed Audio): A positive value, in milliseconds, by which output timestamps are offset to compensate for possible negative timestamps in the input. For example, timestamps from ISO-BMFF after adjusted by EditList could be negative. In transport streams, timestamps are not allowed to be less than zero.segmentDuration()NULLSegment duration in seconds. If single\_segment is specified, this parameter sets the duration of a subsegment; otherwise, this parameter sets the duration of a segment. Actual segment durations may not be exactly as requested.fragmentDuration()NULLFragment duration in seconds. Should not be larger than the segment duration. Actual fragment durations may not be exactly as requested.segmentSapAligned()TRUEForce segments to begin with stream access points.fragmentSapAligned()TRUEForce fragments to begin with stream access points. This flag implies segment\_sap\_aligned.The implementation is based on Template-based Segment URL construction described in ISO/IEC 23009-1:2014.

#### Segment Template Formatting

[](#segment-template-formatting)

$ Identifier $Substitution parameterFormat$$is an escape sequence, i.e. “$$” is replaced with a single “$”.Not applicable.$Number$This identifier is substitued with the number of the corresponding Segment.The format tag may be present. If no format tag is present, a default format tag with width=1 shall be used.$Time$This identifier is substituted with the value of the SegmentTimeline@t attribute for the Segment being accessed. Either $Number$ or $Time$ may be used but not both at the same time.The format tag may be present. If no format tag is present, a default format tag with width=1 shall be used.- **Note**: Identifiers $RepresentationID$ and $Bandwidth$ are not supported in this version. Please file an issue if you want it to be supported.

#### DASH Examples

[](#dash-examples)

Please see **[examples/DASH](/examples/dash)** for details.

### HLS

[](#hls)

**[HTTP Live Streaming](https://developer.apple.com/streaming/)** (also known as HLS) is an HTTP-based media streaming communications protocol implemented by Apple Inc. as part of its QuickTime, Safari, OS X, and iOS software. It resembles MPEG-DASH in that it works by breaking the overall stream into a sequence of small HTTP-based file downloads, each download loading one short chunk of an overall potentially unbounded transport stream. As the stream is played, the client may select from a number of different alternate streams containing the same material encoded at a variety of data rates, allowing the streaming session to adapt to the available data rate. At the start of the streaming session, HLS downloads an extended M3U playlist containing the metadata for the various sub-streams which are available.

#### HLS Stream Options

[](#hls-stream-options)

Besides **[Stream Options](#stream-options)** and **[DRM Stream Options](#drm-stream-options)**, you can add options below:

OptionDefaultDescriptionHLSName()NULLMP4 only: include pssh in the encrypted stream.HLSGroupId()NULLFor MP4 with DASH live profile only: Indicates whether to generate ‘sidx’ box in media segments. Note that it is reuqired by spec if segment template contains $Time$ specifier.playlistName()NULLFor MP4 with DASH live profile only: Indicates whether to generate ‘sidx’ box in media segments. Note that it is reuqired by spec if segment template contains $Time$ specifier.iframePlaylistName()NULLTransport stream only (MPEG2-TS, HLS Packed Audio): A positive value, in milliseconds, by which output timestamps are offset to compensate for possible negative timestamps in the input. For example, timestamps from ISO-BMFF after adjusted by EditList could be negative. In transport streams, timestamps are not allowed to be less than zero.HLSCharacteristics()NULLSegment duration in seconds. If single\_segment is specified, this parameter sets the duration of a subsegment; otherwise, this parameter sets the duration of a segment. Actual segment durations may not be exactly as requested.```
$stream1 = $stream1 = HLSStream::input('/the/path/to/the/file')
                        //->other options
```

#### HLS Packaging

[](#hls-packaging)

This library supports HLS content packaging.

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->HLS('output.m3u8')
    ->export();
```

You can add options to your HLS object using a callback method:

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->HLS('output.m3u8', function ($options) {
        return $options->HLSMasterPlaylistOutput();
            //->other options;
    })
    ->export();
```

#### HLS Options

[](#hls-options)

OptionDefaultDescriptionHLSMasterPlaylistOutput()NULLOutput path for the master playlist for HLS. This flag must be used to output HLS.HLSBaseUrl()NULLThe base URL for the Media Playlists and media files listed in the playlists. This is the prefix for the files.HLSKeyUri()NULLThe key uri for ‘identity’ and ‘com.apple.streamingkeydelivery’ (FairPlay) key formats. Ignored if the playlist is not encrypted or not using the above key formats.HLSPlaylistType()NULLVOD, EVENT, or LIVE. This defines the EXT-X-PLAYLIST-TYPE in the HLS specification. For hls\_playlist\_type of LIVE, EXT-X-PLAYLIST-TYPE tag is omitted.timeShiftBufferDepth()NULLGuaranteed duration of the time shifting buffer for LIVE playlists, in seconds.preservedSegmentsOutsideLiveWindow()NULLSegments outside the live window (defined by time\_shift\_buffer\_depth above) are automatically removed except for the most recent X segments defined by this parameter. This is needed to accommodate latencies in various stages of content serving pipeline, so that the segments stay accessible as they may still be accessed by the player. The segments are not removed if the value is zero.defaultLanguage()NULLAny audio/text tracks tagged with this language will have &lt;Role … value=”main” /&gt; in the manifest. This allows the player to choose the correct default language for the content. This applies to both audio and text tracks. The default language for text tracks can be overriden by ‘default\_text\_language’.defaultTextLanguage()NULLSame as above, but this applies to text tracks only, and overrides the default language for text tracks.Also you can add some **[Chunking and MP4 output options](#chunking-and-mp4-output-options)** to your HLS Object(before using these options, please read the `Description`).

- **Note**: Also you can use **[Segment template formatting](#segment-template-formatting)** in your output.
- **Note**: DASH and HLS options can both be specified to output DASH and HLS manifests at the same time. Note that it works only for MP4 outputs.

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->HLS('hls.m3u8')
    ->DASH('dash.mpd')
    ->export();
```

#### HLS Examples

[](#hls-examples)

Please see **[examples/HLS](/examples/hls)** for details.

Live
----

[](#live)

A typical live source is UDP multicast, which is the only live protocol packager supports directly right now.

For other unsupported protocols, you can use FFmpeg to pipe the input. See **[FFmpeg piping](https://google.github.io/shaka-packager/html/tutorials/ffmpeg_piping.html)** for details.

### UDP File Options

[](#udp-file-options)

UDP file is of the form:

```
udp://:[?[&]...]

```

OptionDescriptionbuffer\_sizeUDP maximum receive buffer size in bytes. Note that although it can be set to any value, the actual value is capped by maximum allowed size defined by the underlying operating system. On linux, the maximum size allowed can be retrieved using sysctl net.core.rmem\_max and configured using sysctl -w net.core.rmem\_max=&lt;size\_in\_bytes&gt;.interfaceMulticast group interface address. Only the packets sent to this address are received. Default to “0.0.0.0” if not specified.reuseAllow or disallow reusing UDP sockets.sourceMulticast source ip address. Only the packets sent from this source address are received. Enables Source Specific Multicast (SSM) if set.timeoutUDP timeout in microseconds.#### Example:

[](#example)

```
udp://224.1.2.30:88?interface=10.11.12.13&reuse=1

```

#### HLS Examples

[](#hls-examples-1)

Please see **[examples/Live](/examples/live)** for details.

DRM
---

[](#drm)

Shaka Packager supports fetching encryption keys from Widevine Key Server and PlayReady Key Server. Shaka Packager also supports Raw Keys, for which keys are provided to Shaka Packager directly.

Regardless of which key server you are using, you can instruct Shaka Packager to generate other protection systems in additional to the native protection system from the key server. This allows generating multi-DRM contents easily.

### DRM Stream options

[](#drm-stream-options)

Besides **[Stream Options](#stream-options)**, you can add options below:

OptionDefaultDescriptionskipEncryption()0Optional. If it is set to 1, no encryption of the stream will be made.drmLabel()NULLOptional value for custom DRM label, which defines the encryption key applied to the stream. Typically values include AUDIO, SD, HD, UHD1, UHD2. For raw key, it should be a label defined in –keys. If not provided, the DRM label is derived from stream type (video, audio), resolutions, etc. Note that it is case sensitive.### General encryption options

[](#general-encryption-options)

OptionDefaultDescriptionprotectionScheme()NULLSpecify a protection scheme, ‘cenc’ or ‘cbc1’ or pattern-based protection schemes ‘cens’ or ‘cbcs’.vp9SubsampleEncryption()TRUEEnable / disable VP9 subsample encryptionnovp9SubsampleEncryption()FALSEEnable / disable VP9 subsample encryptionclearLead()NULLClear lead in seconds if encryption is enabled.protectionSystems()NULLProtection systems to be generated. Supported protection systems include Widevine, PlayReady, FairPlay, Marlin, and CommonSystem ().### Widevine Key Server

[](#widevine-key-server)

The easiest way to generate Widevine protected content is to use Widevine Cloud Service.

Shaka Packager can talk to Widevine Cloud Service or any key server that implements **[Common Encryption API for Widevine DRM](http://bit.ly/2vTG4oo)** to fetch encryption keys.

Widevine Common Encryption API supports request validation using either AES or RSA.

Enable encryption with Widevine key server. User should provide either AES signing key (`aesSigningKey()`, `aesSigningIv()`) or RSA signing key (`rsaSigningKeyPath()`).

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->DRM('widevine', function ($options) {
        return $options->keyServerUrl('https://license.uat.widevine.com/cenc/getcontentkey/widevine_test')**
            ->//other options
    })
    ->HLS('hls.m3u8')
    ->DASH('dash.mpd')
    ->export();
```

#### Widevine Options

[](#widevine-options)

Besides **[General encryption options](#general-encryption-options)**, you can add options below:

OptionDefaultDescriptionenableWidevineDecryption()FALSEEnable decryption with Widevine key server. User should provide either AES signing key (`aesSigningKey()`, `aesSigningIv()`) or RSA signing key (`rsaSigningKeyPath()`).keyServerUrl()NULLKey server url. Required for Widevine encryption and decryption.contentId()NULLContent identifier that uniquely identifies the content.policy()NULLThe name of a stored policy, which specifies DRM content rights.maxSdPixels()NULLThe video track is considered SD if its max pixels per frame is no higher than max\_sd\_pixels. Default: 442368 (768 x 576).maxHdPixels()NULLThe video track is considered HD if its max pixels per frame is higher than `maxSdPixels()`, but no higher than max\_hd\_pixels. Default: 2073600 (1920 x 1080).maxUhd1Pixels()NULLThe video track is considered UHD1 if its max pixels per frame is higher than `maxPhdPixels()`, but no higher than max\_uhd1\_pixels. Otherwise it is UHD2. Default: 8847360 (4096 x 2160).signer()NULLThe name of the signer.aesSigningKey()NULLAES signing key in hex string. `aesSigningIv()` is required if aes\_signing\_key is specified. This option is exclusive with `rsaSigningKeyPath()`.aesSigningIv()NULLAES signing iv in hex string.rsaSigningKeyPath()NULLPath to the file containing PKCS#1 RSA private key for request signing. This option is exclusive with `aesSigningKey()`.cryptoPeriodDuration()NULLDefines how often key rotates. If it is non-zero, key rotation is enabled.groupId()NULLIdentifier for a group of licenses.#### Widevine Examples

[](#widevine-examples)

Please see **[examples/DRM/Widevine](/examples/drm/widevine)** for details.

### PlayReady Key Server

[](#playready-key-server)

This library can talk to PlayReady Key Server that implements **[AcquirePackagingData Web Method specification](http://bit.ly/2M9NuOt)** to fetch encryption keys.

Refer to **[DRM](https://google.github.io/shaka-packager/html/tutorials/drm.html)** if you are interested in generating multi-DRM contents.

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->DRM('playReady', function ($options) {
        return $options->playreadyServerUrl('http://playready.get.key')
            ->//other options
    })
    ->HLS('hls.m3u8')
    ->DASH('dash.mpd')
    ->export();
```

#### PlayReady Options

[](#playready-options)

Besides **[General encryption options](#general-encryption-options)**, you can add options below:

OptionDefaultDescriptionplayreadyServerUrl()NULLPlayReady packaging server url.programIdentifier()NULLProgram identifier for packaging request.caFile()NULLAbsolute path to the certificate authority file for the server cert. PEM format. Optional, depends on server configuration.clientCertFile()NULLAbsolute path to client certificate file. Optional, depends on server configuration.clientCertPrivateKeyFile()NULLAbsolute path to the private key file. Optional, depends on server configuration.clientCertPrivateKeyPassword()NULLPassword to the private key file. Optional, depends on server configuration.### Raw Key Server

[](#raw-key-server)

This library supports raw keys, for which keys and key\_ids are provided to Shaka Packager directly.

This is often used if you are managing the encryption keys yourself. It also allows you to support multi-DRM by providing custom PSSHs.

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->DRM('raw', function ($options) {
        return $options->keys('...keys')
            ->//other options
    })
    ->HLS('hls.m3u8')
    ->DASH('dash.mpd')
    ->export();
```

#### Raw Options

[](#raw-options)

Besides **[General encryption options](#general-encryption-options)**, you can add options below:

OptionDefaultDescriptionenableRawKeyDecryption()FALSEEnable decryption with raw key (keys provided in command line).keys()NULLkey\_info\_string is of the form: label=:key\_id=&lt;key\_id&gt;:key=label can be an arbitrary string or a predefined DRM label like AUDIO, SD, HD, etc. Label with an empty string indicates the default key and key\_id.iv()NULLIV in hex string format. If not specified, a random IV will be generated. This flag should only be used for testing. IV must be either 8 bytes (16 digits HEX) or 16 bytes (32 digits in HEX).pssh()NULLOne or more concatenated PSSH boxes in hex string format. If neither this flag nor –protection\_systems is specified, a v1 common PSSH box will be generated.#### pssh-box (Utility to generate PSSH boxes)

[](#pssh-box-utility-to-generate-pssh-boxes)

#### Raw Examples

[](#raw-examples)

Please see **[examples/DRM/Raw](/examples/drm/raw)** for details.

Ad Insertion
------------

[](#ad-insertion)

This package does not do Ad Insertion directly, but it can precondition content for **[Dynamic Ad Insertion](https://support.google.com/admanager/answer/7295798?hl=en)** with Google Ad Manager.

Both DASH and HLS are supported.

```
$export = $shaka->streams($stream1, $stream2, ...)
    ->mediaPackaging()
    ->HLS('hls.m3u8', function ($options) {
        return $options->adCues('600;1800;3000');
    })
    ->DASH('dash.mpd', function ($options) {
        return $options->adCues('600;1800;3000');
    })
    ->export();
```

#### Ad Insertion Examples

[](#ad-insertion-examples)

Please see **[examples/adInsertion](/examples/adInsertion)** for details.

Several Open Source Players
---------------------------

[](#several-open-source-players)

- **[DASH and HLS on Web: Shaka Player](https://github.com/google/shaka-player)**
- **[DASH on Web: dash.js](https://github.com/Dash-Industry-Forum/dash.js)**
- **[HLS on Web: hls.js](https://github.com/video-dev/hls.js)**
- **[DASH and HLS on Android: ExoPlayer](https://github.com/google/ExoPlayer)**

Contributing and Reporting Bugs
-------------------------------

[](#contributing-and-reporting-bugs)

I'd love your help in improving, correcting, adding to the specification. Please **[file an issue](https://github.com/aminyazdanpanah/shaka-php/issues)** or **[submit a pull request](https://github.com/aminyazdanpanah/shaka-php/pulls)**.

- Please see **[Contributing File](https://github.com/aminyazdanpanah/shaka-php/blob/master/CONTRIBUTING.md)** for more information.
- If you have any questions or you want to report a bug, please just **[file an issue](https://github.com/aminyazdanpanah/shaka-php/issues)**
- If you discover a security vulnerability within this package, please see **[SECURITY File](https://github.com/aminyazdanpanah/shaka-php/blob/master/SECURITY.md)** for more information to help with that.

**NOTE:** If you have any questions about this package or Shaka Packager, please **DO NOT** send an email to me(or submit the contact form on my website). Emails relate to these issues **will be ignored**.

Credits
-------

[](#credits)

- **[Amin Yazdanpanah](http://www.aminyazdanpanah.com/?u=github.com/aminyazdanpanah/shaka-php)**

License
-------

[](#license)

The MIT License (MIT). Please see **[License File](https://github.com/aminyazdanpanah/shaka-php/blob/master/LICENSE)** for more information.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 87.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~663 days

Total

5

Last Release

19d ago

PHP version history (3 changes)v1.0PHP ^7.1

v1.0.1PHP ^7.2

v1.0.5PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3193929?v=4)[Amin Yazdanpanah](/maintainers/aminyazdanpanah)[@aminyazdanpanah](https://github.com/aminyazdanpanah)

---

Top Contributors

[![aminyazdanpanah](https://avatars.githubusercontent.com/u/3193929?v=4)](https://github.com/aminyazdanpanah "aminyazdanpanah (50 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (4 commits)")[![volman-dev](https://avatars.githubusercontent.com/u/26905814?v=4)](https://github.com/volman-dev "volman-dev (2 commits)")[![kfeng0806](https://avatars.githubusercontent.com/u/8554040?v=4)](https://github.com/kfeng0806 "kfeng0806 (1 commits)")

---

Tags

dashgooglehlslaravellaravel-5-packagephpphp7shakashaka-packagershaka-playerstreamingvideovideo-streamingphplaravelgooglelaravel-packagevideopackagerlivehlsdashmpeg-dashDRMshakawidevinepalyreadyraw-key

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aminyazdanpanah-php-shaka/health.svg)

```
[![Health](https://phpackages.com/badges/aminyazdanpanah-php-shaka/health.svg)](https://phpackages.com/packages/aminyazdanpanah-php-shaka)
```

###  Alternatives

[aminyazdanpanah/php-ffmpeg-video-streaming

📼 PHP FFMpeg - Video Streaming - DASH, HLS http://video.aminyazdanpanah.com

544287.4k9](/packages/aminyazdanpanah-php-ffmpeg-video-streaming)[mostafaznv/nova-video

Video Field for Laravel Nova

22458.9k2](/packages/mostafaznv-nova-video)[bitmovin/bitmovin-php

PHP-Client which enables you to seamlessly integrate the Bitmovin API into your existing projects

2059.9k](/packages/bitmovin-bitmovin-php)[achyutn/laravel-hls

A package to convert video files to HLS with rotating key encryption.

1321.5k](/packages/achyutn-laravel-hls)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
