foxws / laravel-media
Probe, encode, package and stream media in Laravel with ffmpeg.
Fund package maintenance!
Requires
- php: ^8.4
- ext-openssl: *
- illuminate/bus: ^13.0
- illuminate/console: ^13.0
- illuminate/contracts: ^13.0
- illuminate/filesystem: ^13.0
- illuminate/process: ^13.0
- illuminate/support: ^13.0
- psr/log: ^3.0
- symfony/process: ^7.4 || ^8.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pao: ^1.0
- laravel/pint: ^1.29
- league/flysystem-aws-s3-v3: ^3.35
- orchestra/testbench: ^11.0
- pestphp/pest: ^5.0
- pestphp/pest-plugin-laravel: ^5.0
- pestphp/pest-plugin-type-coverage: ^5.0.2
- phpstan/extension-installer: ^1.4
Suggests
- league/flysystem-aws-s3-v3: Required for concurrent and multipart uploads to S3 disks (^3.35).
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.2
- 0.1.1
- 0.1.0
- dev-public-number
- dev-readme-docs-site
- dev-fake-add-on-results
- dev-runner-stderr-streaming
- dev-gpu-decode-fallback
- dev-hardware-fallback
- dev-encoded-renditions
- dev-playable-hardware
- dev-playable-media
- dev-align-ladder-keyframes
- dev-fix-falsy-encrypted-sample
- dev-fit-thumbnail-grid
- dev-media-config
This package is auto-updated.
Last update: 2026-10-06 10:54:15 UTC
README
Probe, encode, package and stream audio and video in Laravel with ffprobe and ffmpeg, on any Laravel disk.
- Probe files into typed streams, chapters and formats, and validate uploads by what they really contain.
- Encode with presets, filters, watermarks, HDR to SDR tone mapping, several outputs in one run, and rendition ladders with optional GPU encoding.
- Process clips, frames, subtitles, scene detection, reels and seek-preview thumbnail sprites.
- Stream HLS (CMAF or MPEG-TS) and DASH straight from the stored files, cutting segments on request like nginx-vod-module, with per-request encryption, subtitles, thumbnails, chapters, trick play and multiple audio languages.
- Package renditions into static HLS and DASH with ClearKey encryption, and serve private manifests with signed URLs.
- Export to local or S3 disks with concurrent multipart uploads, and follow progress, events and retryable failures from queued jobs.
- Test without ffmpeg using
Media::fake().
It builds ffmpeg commands directly, without php-ffmpeg underneath, so any ffmpeg option is available without waiting on a package release.
See the full documentation: Installation, Opening and probing, Encoding, Streaming, Packaging, Queues, progress and errors, Testing, Configuration, Extending.
Requirements
- PHP 8.4 or higher, with the OpenSSL extension
- Laravel 13
- ffmpeg and ffprobe
league/flysystem-aws-s3-v3for S3 disks
Installation
composer require foxws/laravel-media
php artisan vendor:publish --tag="media-config"
Check that ffmpeg and ffprobe are found:
php artisan media:info
See Installation for the scheduled commands and queue setup.
Quick start
Probe a file and encode a clip of it to another disk:
use Foxws\Media\Encoding\Format; use Foxws\Media\Facades\Media; $media = Media::fromDisk('s3')->open('videos/clip.mp4'); $media->probe()->duration(); // 93.4 $media->probe()->videoStream()?->height; // 1080 $media->ffmpeg() ->clip(from: 12.5, to: 40) ->inFormat(Format::h264(crf: 22)) ->toDisk('clips') ->save('intro.mp4');
Encode renditions once, then stream them as HLS and DASH without packaging them first:
use Foxws\Media\Encoding\Ladder; use Foxws\Media\Facades\MediaStream; // in a queued job $result = Media::fromDisk('uploads')->open($upload) ->ladder(Ladder::standard(), "videos/{$video->id}/{height}p.mp4") ->toDisk('videos') ->save(); // AppServiceProvider::boot() MediaStream::define('videos', fn (Video $video) => Media::fromDisk('videos')->open($video->renditions) ->stream() ->withChapters() ->withTrickPlay()); // routes/web.php Route::middleware('auth')->group(fn () => Route::mediaStream('videos/{video}', 'videos')); // the URL to give the player MediaStream::url('videos', ['video' => $video]);
See Streaming for subtitles, thumbnails, encryption and the segment cache.
Testing
composer test
Links
Credits
This package started from ideas in Laravel FFMpeg and nginx-vod-module.
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.