PHPackages                             foxws/laravel-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. foxws/laravel-shaka

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

foxws/laravel-shaka
===================

A Laravel package to interact with Shaka Packager for media packaging.

2.0.1(2mo ago)23.1k↓18.9%MITPHPPHP ^8.3CI passing

Since Dec 19Pushed 1mo agoCompare

[ Source](https://github.com/foxws/laravel-shaka)[ Packagist](https://packagist.org/packages/foxws/laravel-shaka)[ Docs](https://github.com/foxws/laravel-shaka)[ GitHub Sponsors](https://github.com/Foxws)[ RSS](/packages/foxws-laravel-shaka/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (38)Versions (30)Used By (0)

Laravel Shaka Packager
======================

[](#laravel-shaka-packager)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3ce4d8dfbee5ac0e4752a1023e84de6a70ac4e7f8bc941d1699af1ecf96b4ead/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f7877732f6c61726176656c2d7368616b612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/foxws/laravel-shaka)[![GitHub Tests Action Status](https://camo.githubusercontent.com/5ee36b8fdd22d00790133f26db0df90a4d0662523f84bf92acb000749a6335b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f666f7877732f6c61726176656c2d7368616b612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/foxws/laravel-shaka/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2a11398724fdd3951572424567f4752157235a60602eb6cfd02e91e2fd0bb679/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f666f7877732f6c61726176656c2d7368616b612f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/foxws/laravel-shaka/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e631456f2bc45b60315604cd90cb854c76eb7ba5961f8d42c40e9a43be10f4cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666f7877732f6c61726176656c2d7368616b612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/foxws/laravel-shaka)

A Laravel integration for [Google's Shaka Packager](https://github.com/shaka-project/shaka-packager), enabling you to create adaptive streaming content (HLS, DASH) with a fluent, Laravel-style API.

```
use Foxws\Shaka\Facades\Shaka;

$result = Shaka::fromDisk('s3')
    ->open('videos/input.mp4')
    ->addVideoStream('videos/input.mp4', 'video_1080p.mp4', ['bandwidth' => '5000000'])
    ->addVideoStream('videos/input.mp4', 'video_720p.mp4', ['bandwidth' => '3000000'])
    ->addAudioStream('videos/input.mp4', 'audio.mp4')
    ->withHlsMasterPlaylist('master.m3u8')
    ->withSegmentDuration(6)
    ->export()
    ->toDisk('export')
    ->save();
```

Features
--------

[](#features)

- 🎬 **Fluent API** - Laravel-style chainable methods
- 📁 **Multiple Disks** - Works with local, S3, and custom filesystems
- 🎯 **Adaptive Bitrate** - Create multi-quality streams easily
- 🔒 **Encryption &amp; DRM** - Built-in support for content protection
- 📺 **HLS &amp; DASH** - Support for both streaming protocols
- 🧪 **Testable** - Clean architecture with mockable components
- 📝 **Type-Safe** - Full PHP 8.1+ type declarations

Documentation
-------------

[](#documentation)

📚 **[Full Documentation](docs/README.md)**

- [Quick Reference](docs/QUICK_REFERENCE.md) - Complete API reference
- [AES Encryption](docs/AES_ENCRYPTION.md) - Encryption with key rotation
- [Architecture Overview](docs/ARCHITECTURE.md) - Understanding the design
- [Configuration](docs/CONFIGURATION.md) - Configuring the package

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

[](#requirements)

- PHP 8.3 or higher
- Laravel 12.x or higher
- Shaka Packager binary installed on your system or Docker container

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

[](#installation)

Install the package via composer:

```
composer require foxws/laravel-shaka
```

Publish the config file:

```
php artisan vendor:publish --tag="shaka-config"
```

### Installing Shaka Packager

[](#installing-shaka-packager)

Install Shaka Packager binary on your system. Visit the [Shaka Packager releases](https://github.com/shaka-project/shaka-packager/releases) page for installation instructions.

### Verify Installation

[](#verify-installation)

After installation, verify that Shaka Packager is properly configured:

```
php artisan shaka:info
```

This will check:

- Binary exists and is executable
- Can retrieve version information
- Configuration is properly set up
- Temporary directory is accessible

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use Foxws\Shaka\Facades\Shaka;

$result = Shaka::open('input.mp4')
    ->addVideoStream('input.mp4', 'video.mp4')
    ->addAudioStream('input.mp4', 'audio.mp4')
    ->withHlsMasterPlaylist('master.m3u8')
    ->export()
    ->save();
```

### Adaptive Bitrate Streaming

[](#adaptive-bitrate-streaming)

```
$result = Shaka::open('input.mp4')
    ->addVideoStream('input.mp4', 'video_1080p.mp4', ['bandwidth' => '5000000'])
    ->addVideoStream('input.mp4', 'video_720p.mp4', ['bandwidth' => '3000000'])
    ->addVideoStream('input.mp4', 'video_480p.mp4', ['bandwidth' => '1500000'])
    ->addAudioStream('input.mp4', 'audio.mp4')
    ->withHlsMasterPlaylist('master.m3u8')
    ->withSegmentDuration(6)
    ->export()
    ->save();
```

### Working with Different Disks

[](#working-with-different-disks)

```
$result = Shaka::fromDisk('s3')
    ->open('videos/input.mp4')
    ->addVideoStream('videos/input.mp4', 'video.mp4')
    ->addAudioStream('videos/input.mp4', 'audio.mp4')
    ->withHlsMasterPlaylist('master.m3u8')
    ->export()
    ->toDisk('export') // Save output to a different disk (e.g., local, s3, etc.)
    ->toPath('exports/') // (Optional) Save to a subdirectory on the target disk
    ->save();
```

### HLS with Encryption

[](#hls-with-encryption)

```
// Basic encryption with auto-generated AES-128 key
Shaka::open('input.mp4')
    ->addVideoStream('input.mp4', 'video.mp4')
    ->addAudioStream('input.mp4', 'audio.mp4')
    ->withHlsMasterPlaylist('master.m3u8')
    ->withAESEncryption()  // Auto-generates key with 'cbc1' scheme
    ->export()
    ->save();

// With key rotation (generates key_0.key, key_1.key, etc.)
Shaka::open('input.mp4')
    ->addVideoStream('input.mp4', 'video.mp4')
    ->addAudioStream('input.mp4', 'audio.mp4')
    ->withHlsMasterPlaylist('master.m3u8')
    ->withAESEncryption()
    ->withKeyRotationDuration(60)  // Rotate every 60 seconds
    ->export()
    ->toDisk('s3')
    ->save();
```

See [AES Encryption Guide](docs/AES_ENCRYPTION.md) for complete documentation.

### Dynamic URL Resolvers (HLS &amp; DASH)

[](#dynamic-url-resolvers-hls--dash)

Serve encrypted streaming content with S3 signed URLs:

**HLS Example:**

```
use Foxws\Shaka\Http\DynamicHLSPlaylist;
use Illuminate\Support\Facades\Storage;

public function playlist(Video $video)
{
    return (new DynamicHLSPlaylist('s3'))
        ->open("videos/{$video->id}/master.m3u8")
        ->setKeyUrlResolver(fn ($key) => Storage::disk('s3')->temporaryUrl(
            "videos/{$video->id}/{$key}",
            now()->addHour()
        ))
        ->setMediaUrlResolver(fn ($file) => Storage::disk('s3')->temporaryUrl(
            "videos/{$video->id}/{$file}",
            now()->addHours(2)
        ))
        ->toResponse(request());
}
```

**DASH Example:**

```
use Foxws\Shaka\Http\DynamicDASHManifest;
use Illuminate\Support\Facades\Storage;

public function manifest(Video $video)
{
    return (new DynamicDASHManifest('s3'))
        ->open("videos/{$video->id}/manifest.mpd")
        ->setKeyUrlResolver(fn ($key) => Storage::disk('s3')->temporaryUrl(
            "videos/{$video->id}/{$key}",
            now()->addHour()
        ))
        ->setMediaUrlResolver(fn ($file) => Storage::disk('s3')->temporaryUrl(
            "videos/{$video->id}/{$file}",
            now()->addHours(2)
        ))
        ->setInitUrlResolver(fn ($file) => Storage::disk('s3')->temporaryUrl(
            "videos/{$video->id}/{$file}",
            now()->addHours(2)
        ))
        ->toResponse(request());
}
```

**Use cases for URL resolvers:**

- 🔐 Generate signed URLs for secure content delivery
- 🌐 Integrate with CDN services
- 🏢 Support multi-tenant applications
- 🔄 Implement dynamic key rotation
- 📊 Track media access patterns

See [URL Resolver Examples](examples/UrlResolverExamples.php) and [Documentation](docs/URL_RESOLVERS.md) for more details.

Available Methods
-----------------

[](#available-methods)

### Disk Management

[](#disk-management)

- `fromDisk(string $disk)` - Set the disk to use
- `openFromDisk(string $disk, $paths)` - Set disk and open files in one call
- `getDisk()` - Get the current disk instance

### Media Management

[](#media-management)

- `open($paths)` - Open one or more media files
- `get()` - Get the MediaCollection
- `streams()` - Get auto-generated Stream objects

### Stream Configuration

[](#stream-configuration)

- `addVideoStream(string $input, string $output, array $options = [])` - Add video stream
- `addAudioStream(string $input, string $output, array $options = [])` - Add audio stream
- `addTextStream(string $input, string $output, array $options = [])` - Add text/caption/subtitle stream
- `addStream(array $stream)` - Add custom stream

### Output Configuration

[](#output-configuration)

- `withHlsMasterPlaylist(string $path)` - Set HLS master playlist output
- `withMpdOutput(string $path)` - Set DASH manifest output
- `withSegmentDuration(int $seconds)` - Set segment duration
- `withAESEncryption(string $keyFilename = 'key', ?string $protectionScheme = 'cbc1', ?string $label = null)` - Enable AES-128 encryption
- `withKeyRotationDuration(int $seconds)` - Enable key rotation for encryption
- `toDisk(string $disk)` - Set the target disk for output
- `toPath(string $path)` - Set the target output path (subdirectory)
- `withVisibility(string $visibility)` - Set file visibility (e.g., 'public', 'private')

### Execution &amp; Utilities

[](#execution--utilities)

- `export()` - Execute the packaging operation (returns result object)
- `save(?string $path = null)` - Save outputs to disk (optionally to a specific path)
- `getCommand()` - Get the final command string (for debugging)
- `dd()` - Dump the final command and end the script
- `afterSaving(callable $callback)` - Register a callback to run after saving

### Dynamic URL Resolvers

[](#dynamic-url-resolvers)

**DynamicHLSPlaylist:**

- `new DynamicHLSPlaylist(?string $disk)` - Create HLS playlist processor
- `open(string $path)` - Open a playlist file
- `setKeyUrlResolver(callable $resolver)` - Set resolver for encryption key URLs
- `setMediaUrlResolver(callable $resolver)` - Set resolver for media segment URLs
- `setPlaylistUrlResolver(callable $resolver)` - Set resolver for sub-playlist URLs
- `get()` - Get processed playlist content
- `all()` - Get all processed playlists (master + segments)
- `toResponse($request)` - Return as HTTP response

**DynamicDASHManifest:**

- `new DynamicDASHManifest(?string $disk)` - Create DASH manifest processor
- `open(string $path)` - Open a manifest file
- `setMediaUrlResolver(callable $resolver)` - Set resolver for media segment URLs
- `setInitUrlResolver(callable $resolver)` - Set resolver for initialization segment URLs
- `get()` - Get processed manifest content
- `toResponse($request)` - Return as HTTP response

See the [Quick Reference](docs/QUICK_REFERENCE.md) for complete API documentation.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability, please report it via a private channel (e.g., email or GitHub issues) rather than publicly disclosing it.

Acknowledgments
---------------

[](#acknowledgments)

This package was inspired by and learned from:

- [Laravel FFmpeg](https://github.com/protonemedia/laravel-ffmpeg) - Architecture patterns and Laravel integration approach.
- [quasarstream/shaka-php](https://github.com/quasarstream/shaka-php) - Shaka Packager wrapper implementation and command building logic.

Much of the existing logic and design patterns from these excellent packages helped shape this implementation. Many thanks to their authors and contributors!

Projects Built on Laravel Shaka Packager
----------------------------------------

[](#projects-built-on-laravel-shaka-packager)

- [Stry](https://github.com/francoism90/stry) - A modern streaming platform built on top of Laravel Shaka Packager.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance89

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% 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 ~4 days

Total

24

Last Release

62d ago

Major Versions

0.9.0 → 1.0.02026-02-06

1.9.0 → 2.0.02026-03-17

PHP version history (3 changes)0.1.0PHP ^8.2||^8.3||^8.4

0.5.0PHP ^8.3||^8.4||^8.5

0.9.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5028905?v=4)[François M.](/maintainers/francoism90)[@francoism90](https://github.com/francoism90)

---

Top Contributors

[![francoism90](https://avatars.githubusercontent.com/u/5028905?v=4)](https://github.com/francoism90 "francoism90 (104 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

dashhlslaravelnetflixpackagershakashaka-packagerstreamingvideolaravelstreamingaudiovideomediapackagerhlsdashshaka

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/foxws-laravel-shaka/health.svg)

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

###  Alternatives

[happyworm/jplayer

jPlayer allows you to create a media player with a consistent interface and experience across all browsers.

4.6k114.2k1](/packages/happyworm-jplayer)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[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.

939.0k1](/packages/aminyazdanpanah-php-shaka)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4719.6k5](/packages/ralphjsmit-laravel-glide)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[saasykit/laravel-open-graphy

An awesome open graph image (social cards) generator package for Laravel.

13057.0k](/packages/saasykit-laravel-open-graphy)

PHPackages © 2026

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