Search by

foxws / laravel-streamer

francoism90

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

Package info

github.com/foxws/laravel-streamer

pkg:composer/foxws/laravel-streamer

Fund package maintenance!

Foxws

Statistics

Installs: 5 968

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

2.3.0 2026-09-24 13:59 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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

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.