foxws / laravel-streamer
A Laravel package to interact with Shaka Streamer for media packaging.
Fund package maintenance!
Requires
- php: ^8.3
- aws/aws-sdk-php: ^3.295
- guzzlehttp/promises: ^2.0||^3.0
- illuminate/contracts: ^12.0||^13.0
- illuminate/filesystem: ^12.0||^13.0
- illuminate/process: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- psr/log: ^3.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- league/flysystem-aws-s3-v3: ^3.35
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0 || ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-24 14:00:37 UTC
README
Runs Shaka Streamer from Laravel. It encodes video into several qualities with FFmpeg, then packages them into HLS and DASH streams. Read the source from any Laravel disk, and write the result to any disk.
If your video is already encoded the way you want it, Laravel Shaka packages it without re-encoding, which is much faster.
See the full documentation: Installation, Usage, URL Resolvers, Queues, Encryption, Configuration, Quick Reference, Troubleshooting.
Requirements
- PHP 8.3 or higher
- Laravel 12 or 13
- Shaka Streamer, with FFmpeg and Shaka Packager
Installation
composer require foxws/laravel-streamer
php artisan vendor:publish --tag="streamer-config"
Install Shaka Streamer with its bundled FFmpeg and Shaka Packager, then check the setup:
pip install shaka-streamer shaka-streamer-binaries php artisan streamer:info
See Installation to use your own FFmpeg and Shaka Packager instead.
Quick start
use Foxws\Streamer\Facades\Streamer; $streamer = Streamer::fromDisk('media')->open('videos/clip.mp4'); try { $streamer ->addVideoStream('videos/clip.mp4', 'video.mp4') ->addAudioStream('videos/clip.mp4', 'audio.mp4') ->withResolutions(['1080p', '720p', '480p']) ->withMpdOutput('index.mpd') ->withHlsMasterPlaylist('master.m3u8') ->export() ->toDisk('s3') ->toPath('streams/clip/') ->save(); } finally { $streamer->cleanupTemporaryFiles(); }
This encodes three qualities, writes one set of segments with both a DASH manifest and an HLS playlist, and uploads them to streams/clip/ on the s3 disk. Run it in a queued job: encoding takes a while.
To serve a private stream, rewrite the playlist with signed URLs when it's requested:
return Streamer::dynamicHLSPlaylist('s3') ->setMediaUrlResolver(fn (string $path) => Storage::disk('s3')->temporaryUrl("streams/clip/{$path}", now()->addHour())) ->open('streams/clip/master.m3u8') ->toResponse($request);
See URL Resolvers and Encryption.
Testing
composer test
Links
- CHANGELOG
- Security policy
- Laravel Shaka, for packaging without re-encoding
- Shaka Streamer documentation
Credits
This package started from ideas in Laravel FFMpeg and shaka-php.
Used by Stry, a self-hosted video streaming app.
AI, specifically Claude, was used to help build this package. All AI-assisted output is reviewed by me, and I retain final say over everything that is implemented and released.
License
MIT. See License File.