juzaweb/laravel-hls-converter
最新稳定版本:1.0.0
Composer 安装命令:
composer require juzaweb/laravel-hls-converter
包简介
Convert video to HLS with optional multi-resolution support.
README 文档
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.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-05-16