juzaweb / laravel-hls-converter
There is no license information available for the latest version (1.0.0) of this package.
Convert video to HLS with optional multi-resolution support.
1.0.0
2025-05-16 15:14 UTC
Requires
- php: ^8.0
- illuminate/support: ^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^9.14|^10.0|^11.0
This package is auto-updated.
Last update: 2025-05-16 15:22:27 UTC
README
A Laravel-friendly package to convert video files to HLS format (.m3u8
+ .ts
), with support for multiple resolutions. Built on top of FFMpeg and Laravel.
๐ Features
- Convert a video to HLS format
- Support multiple quality outputs (adaptive bitrate streaming)
- Automatically generate
master.m3u8
- Laravel-friendly structure with job support
๐งฐ Requirements
- PHP 8.1 or higher
- Laravel 9 / 10 / 11
- FFmpeg installed on the server
Install FFmpeg:
sudo apt-get install ffmpeg
๐ฆ Installation Package
composer require juzaweb/laravel-hls-converter
๐ Usage
Basic HLS Conversion
use Juzaweb\HLSConverter\HLSConverter; $input = storage_path('app/videos/sample.mp4'); $output = storage_path('app/hls/single'); app(HLSConverter::class)->convert($input, $output);
Convert with multiple resolutions
use Juzaweb\HLSConverter\HLSConverter; $input = storage_path('app/videos/sample.mp4'); $output = storage_path('app/hls/multi'); $resolutions = [ '360p' => ['w' => 640, 'h' => 360, 'bitrate' => '800k'], '480p' => ['w' => 854, 'h' => 480, 'bitrate' => '1200k'], '720p' => ['w' => 1280, 'h' => 720, 'bitrate' => '2500k'], ]; app(HLSConverter::class)->convert($input, $output, $resolutions);
This will generate:
output/
โโโ 360p/
โ โโโ seg_000.ts
โ โโโ index.m3u8
โโโ 480p/
โ โโโ ...
โโโ 720p/
โ โโโ ...
โโโ master.m3u8
๐งช Running Tests
composer test
๐ Example Laravel Job
use Juzaweb\HLSConverter\HLSConverter; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; class ConvertVideoToHLSJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public $tries = 3; public $timeout = 120; public function __construct( protected string $input, protected string $output, protected ?array $resolutions = null ) {} public function handle() { app(HLSConverter::class)->convert($this->input, $this->output, $this->resolutions); } }
๐ License
The HLS Converter is released under the MIT License.